├── .envrc ├── .github ├── actions │ └── setup-go │ │ └── action.yml └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── .goreleaser.yml ├── LICENSE ├── Makefile ├── README.md ├── docs ├── data-sources │ ├── conversation.md │ ├── user.md │ └── usergroup.md ├── index.md └── resources │ ├── conversation.md │ ├── usergroup.md │ ├── usergroup_channels.md │ └── usergroup_members.md ├── examples ├── .gitignore ├── .terraform-version ├── main.tf ├── paid-feature │ ├── main.tf │ └── variables.tf └── variables.tf ├── go.mod ├── go.sum ├── main.go ├── slack ├── cache.go ├── config.go ├── config_test.go ├── data_conversation.go ├── data_user.go ├── data_usergroup.go ├── logger.go ├── provider.go ├── resource_conversation.go ├── resource_usergroup.go ├── resource_usergroup_channels.go ├── resource_usergroup_members.go ├── resource_usergroup_members_test.go ├── server_test.go ├── util.go └── util_test.go └── tools ├── download-provider ├── src └── download-provider.bash └── tools.go /.envrc: -------------------------------------------------------------------------------- 1 | PATH_add "bin" 2 | 3 | export GO111MODULE=on -------------------------------------------------------------------------------- /.github/actions/setup-go/action.yml: -------------------------------------------------------------------------------- 1 | name: Setup go 2 | description: xxx 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: actions/setup-go@v3 7 | with: 8 | go-version: 1.16 9 | - shell: bash 10 | run: echo '${{ github.workspace }}/bin' >> $GITHUB_PATH -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | shellcheck: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: reviewdog/action-shellcheck@v1 15 | with: 16 | reporter: github-pr-review 17 | path: tools 18 | pattern: "*.bash" 19 | fmt: 20 | timeout-minutes: 5 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v3 24 | - uses: ./.github/actions/setup-go 25 | - run: make fmt-check 26 | test: 27 | timeout-minutes: 5 28 | runs-on: ubuntu-latest 29 | steps: 30 | - uses: actions/checkout@v3 31 | - uses: ./.github/actions/setup-go 32 | - run: make test 33 | docscheck: 34 | timeout-minutes: 5 35 | runs-on: ubuntu-latest 36 | if: > 37 | github.event_name == 'push' && 38 | github.head_ref == 'refs/heads/master' 39 | steps: 40 | - uses: actions/checkout@v3 41 | - uses: ./.github/actions/setup-go 42 | - run: make generate 43 | - run: git diff --exit-code --name-only 44 | goreleaser: 45 | timeout-minutes: 10 46 | runs-on: ubuntu-latest 47 | steps: 48 | - uses: actions/checkout@v3 49 | - uses: ./.github/actions/setup-go 50 | - uses: goreleaser/goreleaser-action@v3 51 | with: 52 | version: latest 53 | args: build --snapshot --rm-dist 54 | - uses: actions/upload-artifact@v3 55 | with: 56 | name: providers 57 | path: dist/* 58 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | push: 4 | tags: 5 | - 'v*' 6 | jobs: 7 | test: 8 | timeout-minutes: 5 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: ./.github/actions/setup-go 13 | - run: make test 14 | goreleaser: 15 | needs: 16 | - test 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 15 19 | steps: 20 | - uses: actions/checkout@v3 21 | with: 22 | depth: 0 23 | - uses: ./.github/actions/setup-go 24 | - id: import_gpg 25 | uses: crazy-max/ghaction-import-gpg@v5 26 | with: 27 | gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} 28 | passphrase: ${{ secrets.PASSPHRASE }} 29 | - uses: goreleaser/goreleaser-action@v3 30 | with: 31 | version: latest 32 | args: release --rm-dist 33 | env: 34 | GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | - uses: actions/upload-artifact@v3 37 | with: 38 | name: providers 39 | path: dist/* 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/go,intellij+all,macos,emacs,vim 3 | # Edit at https://www.gitignore.io/?templates=go,intellij+all,macos,emacs,vim 4 | 5 | ### Emacs ### 6 | # -*- mode: gitignore; -*- 7 | *~ 8 | \#*\# 9 | /.emacs.desktop 10 | /.emacs.desktop.lock 11 | *.elc 12 | auto-save-list 13 | tramp 14 | .\#* 15 | 16 | # Org-mode 17 | .org-id-locations 18 | *_archive 19 | 20 | # flymake-mode 21 | *_flymake.* 22 | 23 | # eshell files 24 | /eshell/history 25 | /eshell/lastdir 26 | 27 | # elpa packages 28 | /elpa/ 29 | 30 | # reftex files 31 | *.rel 32 | 33 | # AUCTeX auto folder 34 | /auto/ 35 | 36 | # cask packages 37 | .cask/ 38 | dist/ 39 | 40 | # Flycheck 41 | flycheck_*.el 42 | 43 | # server auth directory 44 | /server/ 45 | 46 | # projectiles files 47 | .projectile 48 | 49 | # directory configuration 50 | .dir-locals.el 51 | 52 | # network security 53 | /network-security.data 54 | 55 | 56 | ### Go ### 57 | # Binaries for programs and plugins 58 | *.exe 59 | *.exe~ 60 | *.dll 61 | *.so 62 | *.dylib 63 | 64 | # Test binary, built with `go test -c` 65 | *.test 66 | 67 | # Output of the go coverage tool, specifically when used with LiteIDE 68 | *.out 69 | 70 | ### Go Patch ### 71 | /vendor/ 72 | /Godeps/ 73 | 74 | ### Intellij+all ### 75 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 76 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 77 | 78 | # User-specific stuff 79 | .idea/**/workspace.xml 80 | .idea/**/tasks.xml 81 | .idea/**/usage.statistics.xml 82 | .idea/**/dictionaries 83 | .idea/**/shelf 84 | 85 | # Generated files 86 | .idea/**/contentModel.xml 87 | 88 | # Sensitive or high-churn files 89 | .idea/**/dataSources/ 90 | .idea/**/dataSources.ids 91 | .idea/**/dataSources.local.xml 92 | .idea/**/sqlDataSources.xml 93 | .idea/**/dynamic.xml 94 | .idea/**/uiDesigner.xml 95 | .idea/**/dbnavigator.xml 96 | 97 | # Gradle 98 | .idea/**/gradle.xml 99 | .idea/**/libraries 100 | 101 | # Gradle and Maven with auto-import 102 | # When using Gradle or Maven with auto-import, you should exclude module files, 103 | # since they will be recreated, and may cause churn. Uncomment if using 104 | # auto-import. 105 | # .idea/modules.xml 106 | # .idea/*.iml 107 | # .idea/modules 108 | 109 | # CMake 110 | cmake-build-*/ 111 | 112 | # Mongo Explorer plugin 113 | .idea/**/mongoSettings.xml 114 | 115 | # File-based project format 116 | *.iws 117 | 118 | # IntelliJ 119 | out/ 120 | 121 | # mpeltonen/sbt-idea plugin 122 | .idea_modules/ 123 | 124 | # JIRA plugin 125 | atlassian-ide-plugin.xml 126 | 127 | # Cursive Clojure plugin 128 | .idea/replstate.xml 129 | 130 | # Crashlytics plugin (for Android Studio and IntelliJ) 131 | com_crashlytics_export_strings.xml 132 | crashlytics.properties 133 | crashlytics-build.properties 134 | fabric.properties 135 | 136 | # Editor-based Rest Client 137 | .idea/httpRequests 138 | 139 | # Android studio 3.1+ serialized cache file 140 | .idea/caches/build_file_checksums.ser 141 | 142 | ### Intellij+all Patch ### 143 | # Ignores the whole .idea folder and all .iml files 144 | # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 145 | 146 | .idea/ 147 | 148 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 149 | 150 | *.iml 151 | modules.xml 152 | .idea/misc.xml 153 | *.ipr 154 | 155 | # Sonarlint plugin 156 | .idea/sonarlint 157 | 158 | ### macOS ### 159 | # General 160 | .DS_Store 161 | .AppleDouble 162 | .LSOverride 163 | 164 | # Icon must end with two \r 165 | Icon 166 | 167 | # Thumbnails 168 | ._* 169 | 170 | # Files that might appear in the root of a volume 171 | .DocumentRevisions-V100 172 | .fseventsd 173 | .Spotlight-V100 174 | .TemporaryItems 175 | .Trashes 176 | .VolumeIcon.icns 177 | .com.apple.timemachine.donotpresent 178 | 179 | # Directories potentially created on remote AFP share 180 | .AppleDB 181 | .AppleDesktop 182 | Network Trash Folder 183 | Temporary Items 184 | .apdisk 185 | 186 | ### Vim ### 187 | # Swap 188 | [._]*.s[a-v][a-z] 189 | [._]*.sw[a-p] 190 | [._]s[a-rt-v][a-z] 191 | [._]ss[a-gi-z] 192 | [._]sw[a-p] 193 | 194 | # Session 195 | Session.vim 196 | 197 | # Temporary 198 | .netrwhist 199 | # Auto-generated tag files 200 | tags 201 | # Persistent undo 202 | [._]*.un~ 203 | 204 | # End of https://www.gitignore.io/api/go,intellij+all,macos,emacs,vim 205 | 206 | terraform-provider-slack 207 | terraform-provider-slack_* -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/hashicorp/terraform-provider-scaffolding/blob/7f8faf519e4fba622fd4f8deb7163b669d9d8a9d/.goreleaser.yml 2 | before: 3 | hooks: 4 | # this is just an example and not a requirement for provider building/publishing 5 | - go mod tidy 6 | builds: 7 | - env: 8 | # goreleaser does not work with CGO, it could also complicate 9 | # usage by users in CI/CD systems like Terraform Cloud where 10 | # they are unable to install libraries. 11 | - CGO_ENABLED=0 12 | mod_timestamp: '{{ .CommitTimestamp }}' 13 | flags: 14 | - -trimpath 15 | ldflags: 16 | - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' 17 | goos: 18 | - freebsd 19 | - windows 20 | - linux 21 | - darwin 22 | goarch: 23 | - amd64 24 | - '386' 25 | - arm 26 | - arm64 27 | ignore: # followed https://github.com/hashicorp/terraform-provider-aws/blob/2590e6359b1ddb1354db633d3c731d119d0f6e97/.goreleaser.yml#L27 28 | - goarch: arm 29 | goos: windows 30 | - goarch: arm64 31 | goos: freebsd 32 | - goarch: arm64 33 | goos: windows 34 | binary: '{{ .ProjectName }}_v{{ .Version }}' 35 | archives: 36 | - format: zip 37 | name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' 38 | checksum: 39 | name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' 40 | algorithm: sha256 41 | signs: 42 | - artifacts: checksum 43 | args: 44 | # if you are using this is a GitHub action or some other automated pipeline, you 45 | # need to pass the batch flag to indicate its not interactive. 46 | - "--batch" 47 | - "--local-user" 48 | - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key 49 | - "--output" 50 | - "${signature}" 51 | - "--detach-sign" 52 | - "${artifact}" 53 | release: 54 | # If you want to manually examine the release before its live, uncomment this line: 55 | # draft: true 56 | changelog: 57 | skip: true -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020- Jumpei Matsuda and all contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | base_version := $(shell git describe --tags --dirty | sed -e 's/^v//g') 2 | 3 | build: 4 | go build -ldflags="-X main.version=$(base_version) -X main.commit=n/a" . 5 | 6 | install-%: build 7 | mkdir -p ~/.terraform.d/plugins/github.com/jmatsu/slack/$(base_version)/${@:install-%=%} 8 | mv terraform-provider-slack ~/.terraform.d/plugins/github.com/jmatsu/slack/$(base_version)/${@:install-%=%}/terraform-provider-slack_v$(base_version) 9 | 10 | fmt: 11 | gofmt -w . 12 | 13 | fmt-check: 14 | gofmt . 15 | 16 | generate: 17 | go generate 18 | 19 | test: 20 | TF_ACC=1 go test ./... -timeout 120m -v -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # terraform-provider-slack 2 | 3 | [![CircleCI](https://circleci.com/gh/jmatsu/terraform-provider-slack.svg?style=svg)](https://circleci.com/gh/jmatsu/terraform-provider-slack) 4 | 5 | This is a [Terraform](https://www.terraform.io/) provider for [Slack](https://slack.com) 6 | 7 | # Installation 8 | 9 | ref: https://registry.terraform.io/providers/jmatsu/slack/latest 10 | 11 | Or build a binary by yourself. 12 | 13 | ```bash 14 | $ go clone ... && cd /path/to/project 15 | $ go mod download 16 | $ go build . 17 | $ mv terraform-provider-slack ~/.terraform.d/plugins/[architecture name]/ 18 | ``` 19 | 20 | See https://www.terraform.io/docs/configuration/providers.html#third-party-plugins for more details. 21 | 22 | # Requirements 23 | 24 | - [Terraform](https://www.terraform.io/downloads.html) >= v0.12.0 (v0.11.x may work but not supported actively) 25 | - Scope: `users:read,users:read.email,usergroups:read,usergroups:write,channels:read,channels:write,groups:read,groups:write` 26 | - `users:read.email` is required since v0.6.0 27 | 28 | # Limitations 29 | 30 | Several resources that require Slack Plus or Enterprise Grid are not supported. e.g. a slack user (not a data source) 31 | 32 | # Resources 33 | 34 | ```hcl 35 | provider "slack" { 36 | # A token must be of an user. A bot user's token cannot be used for usergroup api call. 37 | # To get a token, Botkit is one of recommended methods. 38 | token = "SLACK_TOKEN" 39 | } 40 | 41 | data "slack_user" "..." { 42 | query_type = "id" or "email" 43 | query_value = "" or "" 44 | } 45 | 46 | data "slack_conversation" "..." { 47 | channel_id = 48 | } 49 | 50 | data "slack_usergroup" "..." { 51 | usergroup_id = 52 | } 53 | 54 | resource "slack_conversation" "..." { 55 | name = "" 56 | topic = "..." 57 | purpose = "..." 58 | action_on_destroy = "" # this is required since v0.8.0 59 | is_archive = 60 | is_private = 61 | } 62 | 63 | resource "slack_usergroup" "..." { 64 | handle = "" 65 | name = "" 66 | description = "..." 67 | auto_type = "" or "admins" or "owners" 68 | } 69 | 70 | resource "slack_usergroup_members" "..." { 71 | usergroup_id = "" 72 | members = ["", ...] 73 | } 74 | 75 | resource "slack_usergroup_channels" "..." { 76 | usergroup_id = "" 77 | channels = ["", ...] 78 | } 79 | ``` 80 | 81 | # Import 82 | 83 | ```bash 84 | $ terraform import slack_conversation. 85 | $ terraform import slack_usergroup. 86 | $ terraform import slack_usergroup_members. 87 | $ terraform import slack_usergroup_channels. 88 | ``` 89 | 90 | # Trouble Shooting 91 | 92 | ## Show provider's debug logs 93 | 94 | Enable the provider logging. All custom logs should have `provider=jmatsu/slack` in its body. 95 | 96 | ```bash 97 | # The following expects you are using `slack` as provider name 98 | TF_LOG=json TF_LOG_PROVIDER_SLACK=TRACE ...cmd 99 | ``` 100 | 101 | # Development 102 | 103 | Source codes consist of an entrypoint `main.go` and `slack/**.go`. 104 | 105 | ## Try the built provider in projects 106 | 107 | Build and install the provider into your machine. 108 | 109 | > Currently, only `~/.terraform.d` is supported. 110 | 111 | ```bash 112 | # choose OS_NAME and ARCH of your machine 113 | make install-${OS_NAME}_${ARCH} 114 | ``` 115 | 116 | Use the built provider by specifying the custom source. 117 | 118 | ```terraform 119 | terraform { 120 | required_providers { 121 | slack = { 122 | # please make sure ~/.terraform.d/plugins/github.com/jmatsu/slack/${version}/${OS_NAME}_${ARCH}/terraform-provider-slack_v${version} exists and it's executable. 123 | source = "github.com/jmatsu/slack" 124 | version = "${version}" 125 | } 126 | } 127 | } 128 | ``` 129 | 130 | ## Other commands 131 | 132 | ``` 133 | # Build the binary 134 | make build 135 | 136 | # Run test 137 | make test 138 | 139 | # Apply gofmt (overwrite mode) 140 | make fmt 141 | ``` 142 | 143 | # Release 144 | 145 | CI will build and archive the release artifacts to GitHub Releases and terraform provider registry. 146 | 147 | ``` 148 | version="/\d\.\d\.\d/" 149 | 150 | # please make sure your working branch is same to the default branch. 151 | git tag "v$version" 152 | git push "v$version" 153 | ``` 154 | 155 | # LICENSE 156 | 157 | Under [MIT](./LICENSE) 158 | 159 | # Maintainers 160 | 161 | @jmatsu, @billcchung -------------------------------------------------------------------------------- /docs/data-sources/conversation.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack_conversation Data Source - terraform-provider-slack" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack_conversation (Data Source) 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `channel_id` (String) 21 | 22 | ### Optional 23 | 24 | - `purpose` (String) 25 | - `topic` (String) 26 | 27 | ### Read-Only 28 | 29 | - `created` (Number) 30 | - `creator` (String) 31 | - `id` (String) The ID of this resource. 32 | - `is_archived` (Boolean) 33 | - `is_ext_shared` (Boolean) 34 | - `is_org_shared` (Boolean) 35 | - `is_private` (Boolean) 36 | - `is_shared` (Boolean) 37 | - `name` (String) 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/data-sources/user.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack_user Data Source - terraform-provider-slack" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack_user (Data Source) 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `query_type` (String) 21 | - `query_value` (String) 22 | 23 | ### Read-Only 24 | 25 | - `has_2fa` (Boolean) 26 | - `id` (String) The ID of this resource. 27 | - `is_admin` (Boolean) 28 | - `is_bot` (Boolean) 29 | - `is_owner` (Boolean) 30 | - `name` (String) 31 | - `real_name` (String) 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/data-sources/usergroup.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack_usergroup Data Source - terraform-provider-slack" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack_usergroup (Data Source) 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `usergroup_id` (String) 21 | 22 | ### Optional 23 | 24 | - `description` (String) 25 | 26 | ### Read-Only 27 | 28 | - `auto_type` (String) 29 | - `handle` (String) 30 | - `id` (String) The ID of this resource. 31 | - `name` (String) 32 | - `team_id` (String) 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack Provider" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack Provider 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `token` (String) The OAuth token used to connect to Slack. 21 | -------------------------------------------------------------------------------- /docs/resources/conversation.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack_conversation Resource - terraform-provider-slack" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack_conversation (Resource) 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `action_on_destroy` (String) Either of none or archive 21 | - `is_private` (Boolean) 22 | - `name` (String) 23 | 24 | ### Optional 25 | 26 | - `is_archived` (Boolean) 27 | - `purpose` (String) 28 | - `topic` (String) 29 | 30 | ### Read-Only 31 | 32 | - `created` (Number) 33 | - `creator` (String) 34 | - `id` (String) The ID of this resource. 35 | - `is_ext_shared` (Boolean) 36 | - `is_org_shared` (Boolean) 37 | - `is_shared` (Boolean) 38 | 39 | 40 | -------------------------------------------------------------------------------- /docs/resources/usergroup.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack_usergroup Resource - terraform-provider-slack" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack_usergroup (Resource) 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `handle` (String) 21 | 22 | ### Optional 23 | 24 | - `auto_type` (String) 25 | - `description` (String) 26 | - `name` (String) 27 | 28 | ### Read-Only 29 | 30 | - `id` (String) The ID of this resource. 31 | - `team_id` (String) 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/resources/usergroup_channels.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack_usergroup_channels Resource - terraform-provider-slack" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack_usergroup_channels (Resource) 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `channels` (Set of String) 21 | - `usergroup_id` (String) 22 | 23 | ### Read-Only 24 | 25 | - `id` (String) The ID of this resource. 26 | 27 | 28 | -------------------------------------------------------------------------------- /docs/resources/usergroup_members.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "slack_usergroup_members Resource - terraform-provider-slack" 4 | subcategory: "" 5 | description: |- 6 | 7 | --- 8 | 9 | # slack_usergroup_members (Resource) 10 | 11 | 12 | 13 | 14 | 15 | 16 | ## Schema 17 | 18 | ### Required 19 | 20 | - `members` (Set of String) 21 | - `usergroup_id` (String) 22 | 23 | ### Read-Only 24 | 25 | - `id` (String) The ID of this resource. 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | terraform.tfvars 2 | .terraform/ 3 | *.log 4 | *.tfstate 5 | *.backup -------------------------------------------------------------------------------- /examples/.terraform-version: -------------------------------------------------------------------------------- 1 | 0.12.13 -------------------------------------------------------------------------------- /examples/main.tf: -------------------------------------------------------------------------------- 1 | provider "slack" { 2 | version = "= 0.0.0-snapshot" 3 | token = var.slack_token 4 | } 5 | 6 | data "slack_user" "sample_1" { 7 | query_type = "id" 8 | query_value = var.example_data_user_id 9 | } 10 | 11 | data "slack_user" "sample_2" { 12 | query_type = "name" 13 | query_value = var.example_data_user_name 14 | } 15 | 16 | data "slack_user" "sample_3" { 17 | query_type = "email" 18 | query_value = var.example_data_user_email 19 | } 20 | 21 | data "slack_channel" "existing_sample_1" { 22 | channel_id = var.example_data_channel_id 23 | } 24 | 25 | data "slack_group" "existing_sample_2" { 26 | group_id = var.example_data_group_id 27 | } 28 | 29 | resource "slack_channel" "new" { 30 | name = "zz_terraform_example_channel_new-${var.salt}}" 31 | } 32 | 33 | resource "slack_group" "new" { 34 | name = "zz_terraform_example_group_new-${var.salt}" 35 | } 36 | 37 | resource "slack_channel" "managed" { 38 | name = "zz_terraform_example_channel_managed-1" 39 | purpose = "change here" 40 | } 41 | 42 | resource "slack_group" "managed" { 43 | name = "zz_terraform_example_group_managed-1" 44 | purpose = "change here" 45 | } 46 | -------------------------------------------------------------------------------- /examples/paid-feature/main.tf: -------------------------------------------------------------------------------- 1 | provider "slack" { 2 | version = "= 0.0.0-snapshot" 3 | token = var.slack_token 4 | } 5 | 6 | data "slack_usergroup" "example" { 7 | usergroup_id = var.example_data_usergroup_id 8 | } 9 | 10 | data "slack_user" "sample_1" { 11 | query_type = "id" 12 | query_value = var.example_data_user_id 13 | } 14 | 15 | data "slack_user" "sample_2" { 16 | query_type = "name" 17 | query_value = var.example_data_user_name 18 | } 19 | 20 | data "slack_user" "sample_3" { 21 | query_type = "name" 22 | query_value = var.example_data_user_email 23 | } 24 | 25 | resource "slack_usergroup" "new" { 26 | handle = "zz_terraform_example_new_${var.salt}" 27 | name = "New usergroup for terraform example ${var.salt}" 28 | } 29 | 30 | resource "slack_usergroup" "managed" { 31 | handle = "zz_terraform_example_managed_2" 32 | name = "Managed usergroup for terraform example 2" 33 | } 34 | 35 | resource "slack_usergroup" "new2" { 36 | handle = "zz_terraform_example_new_x" 37 | name = "New usergroup for terraform example x" 38 | } 39 | 40 | resource "slack_usergroup_channels" "example" { 41 | usergroup_id = slack_usergroup.managed.id 42 | channels = [var.example_data_channel_id] 43 | } -------------------------------------------------------------------------------- /examples/paid-feature/variables.tf: -------------------------------------------------------------------------------- 1 | variable "slack_token" { 2 | type = string 3 | } 4 | 5 | variable "example_data_user_id" { 6 | type = string 7 | } 8 | 9 | variable "example_data_user_name" { 10 | type = string 11 | } 12 | 13 | variable "example_data_user_email" { 14 | type = string 15 | } 16 | 17 | variable "example_data_channel_id" { 18 | type = string 19 | } 20 | 21 | variable "example_data_usergroup_id" { 22 | type = string 23 | } 24 | 25 | variable "salt" { 26 | type = string 27 | } -------------------------------------------------------------------------------- /examples/variables.tf: -------------------------------------------------------------------------------- 1 | variable "slack_token" { 2 | type = string 3 | } 4 | 5 | variable "example_data_user_id" { 6 | type = string 7 | } 8 | 9 | variable "example_data_user_name" { 10 | type = string 11 | } 12 | 13 | variable "example_data_user_email" { 14 | type = string 15 | } 16 | 17 | variable "example_data_channel_id" { 18 | type = string 19 | } 20 | 21 | variable "example_data_group_id" { 22 | type = string 23 | } 24 | 25 | variable "salt" { 26 | type = string 27 | } -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/jmatsu/terraform-provider-slack 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/agext/levenshtein v1.2.3 // indirect 7 | github.com/gorilla/websocket v1.5.0 // indirect 8 | github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 9 | github.com/hashicorp/hcl/v2 v2.13.0 // indirect 10 | github.com/hashicorp/terraform-plugin-docs v0.10.1 11 | github.com/hashicorp/terraform-plugin-log v0.4.1 // indirect 12 | github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0 13 | github.com/hashicorp/terraform-registry-address v0.0.0-20220510144317-d78f4a47ae27 // indirect 14 | github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect 15 | github.com/mitchellh/go-wordwrap v1.0.1 // indirect 16 | github.com/oklog/run v1.1.0 // indirect 17 | github.com/slack-go/slack v0.11.0 18 | github.com/vmihailenco/tagparser v0.1.2 // indirect 19 | go.uber.org/atomic v1.9.0 // indirect 20 | go.uber.org/multierr v1.8.0 // indirect 21 | go.uber.org/zap v1.21.0 // indirect 22 | golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect 23 | golang.org/x/sys v0.0.0-20220624220833-87e55d714810 // indirect 24 | google.golang.org/appengine v1.6.7 // indirect 25 | google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f // indirect 26 | gopkg.in/djherbis/times.v1 v1.3.0 27 | ) 28 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 4 | github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= 5 | github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= 6 | github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= 7 | github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= 8 | github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= 9 | github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI= 10 | github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= 11 | github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= 12 | github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= 13 | github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= 14 | github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= 15 | github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= 16 | github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= 17 | github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= 18 | github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= 19 | github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= 20 | github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= 21 | github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= 22 | github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= 23 | github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= 24 | github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= 25 | github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= 26 | github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= 27 | github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= 28 | github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= 29 | github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= 30 | github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= 31 | github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= 32 | github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= 33 | github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= 34 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 35 | github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= 36 | github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 37 | github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= 38 | github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= 39 | github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= 40 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 41 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 42 | github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 43 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 44 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= 45 | github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= 46 | github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= 47 | github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 48 | github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 49 | github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 50 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 51 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 52 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 53 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 54 | github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= 55 | github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= 56 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 57 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 58 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= 59 | github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= 60 | github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= 61 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 62 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 63 | github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= 64 | github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= 65 | github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 66 | github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= 67 | github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= 68 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 69 | github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= 70 | github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= 71 | github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= 72 | github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= 73 | github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= 74 | github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= 75 | github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= 76 | github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= 77 | github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= 78 | github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= 79 | github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= 80 | github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= 81 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 82 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 83 | github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 84 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 85 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 86 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 87 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 88 | github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= 89 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 90 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 91 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 92 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 93 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 94 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= 95 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 96 | github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 97 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 98 | github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= 99 | github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 100 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 101 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 102 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 103 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 104 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 105 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 106 | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 107 | github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= 108 | github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= 109 | github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 110 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 111 | github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 112 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 113 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 114 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 115 | github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= 116 | github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 117 | github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= 118 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 119 | github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= 120 | github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 121 | github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= 122 | github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= 123 | github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 124 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 125 | github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= 126 | github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= 127 | github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= 128 | github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= 129 | github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= 130 | github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= 131 | github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw= 132 | github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= 133 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 134 | github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= 135 | github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= 136 | github.com/hashicorp/go-plugin v1.4.4 h1:NVdrSdFRt3SkZtNckJ6tog7gbpRrcbOjQi/rgF7JYWQ= 137 | github.com/hashicorp/go-plugin v1.4.4/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= 138 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 139 | github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= 140 | github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 141 | github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 142 | github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 143 | github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 144 | github.com/hashicorp/go-version v1.5.0 h1:O293SZ2Eg+AAYijkVK3jR786Am1bhDEh2GHT0tIVE5E= 145 | github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 146 | github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak= 147 | github.com/hashicorp/hc-install v0.3.2 h1:oiQdJZvXmkNcRcEOOfM5n+VTsvNjWQeOjfAoO6dKSH8= 148 | github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs= 149 | github.com/hashicorp/hcl/v2 v2.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= 150 | github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= 151 | github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= 152 | github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= 153 | github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= 154 | github.com/hashicorp/terraform-exec v0.16.1 h1:NAwZFJW2L2SaCBVZoVaH8LPImLOGbPLkSHy0IYbs2uE= 155 | github.com/hashicorp/terraform-exec v0.16.1/go.mod h1:aj0lVshy8l+MHhFNoijNHtqTJQI3Xlowv5EOsEaGO7M= 156 | github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= 157 | github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= 158 | github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= 159 | github.com/hashicorp/terraform-plugin-docs v0.10.1 h1:jiVYfhJ/hVXDAQN2XjLK3WH1A/YHgFCrFXPpxibvmjc= 160 | github.com/hashicorp/terraform-plugin-docs v0.10.1/go.mod h1:47ZcsxMUJxAjGzHf+dZ9q78oYf4PeJxO1N+i5XDtXBc= 161 | github.com/hashicorp/terraform-plugin-go v0.9.1 h1:vXdHaQ6aqL+OF076nMSBV+JKPdmXlzG5mzVDD04WyPs= 162 | github.com/hashicorp/terraform-plugin-go v0.9.1/go.mod h1:ItjVSlQs70otlzcCwlPcU8FRXLdO973oYFRZwAOxy8M= 163 | github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg= 164 | github.com/hashicorp/terraform-plugin-log v0.4.1 h1:xpbmVhvuU3mgHzLetOmx9pkOL2rmgpu302XxddON6eo= 165 | github.com/hashicorp/terraform-plugin-log v0.4.1/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= 166 | github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0 h1:Qr5fWNg1SPSfCRMtou67Y6Kcy9UnMYRNlIJTKRuUvXU= 167 | github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0/go.mod h1:b+LFg8WpYgFgvEBP/6Htk5H9/pJp1V1E8NJAekfH2Ws= 168 | github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= 169 | github.com/hashicorp/terraform-registry-address v0.0.0-20220510144317-d78f4a47ae27 h1:IOawOnLgKntezAV3oJs17rkhXha+h0EF5OMjb2KFlYc= 170 | github.com/hashicorp/terraform-registry-address v0.0.0-20220510144317-d78f4a47ae27/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= 171 | github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= 172 | github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= 173 | github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= 174 | github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= 175 | github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 h1:xixZ2bWeofWV68J+x6AzmKuVM/JWCQwkWm6GW/MUR6I= 176 | github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= 177 | github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= 178 | github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= 179 | github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= 180 | github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= 181 | github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= 182 | github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= 183 | github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= 184 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= 185 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= 186 | github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= 187 | github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= 188 | github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= 189 | github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= 190 | github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= 191 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 192 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 193 | github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 194 | github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= 195 | github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= 196 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 197 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 198 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 199 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 200 | github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= 201 | github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= 202 | github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= 203 | github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= 204 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 205 | github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 206 | github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= 207 | github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= 208 | github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= 209 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 210 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 211 | github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= 212 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 213 | github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= 214 | github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= 215 | github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA= 216 | github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ= 217 | github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= 218 | github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= 219 | github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= 220 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 221 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 222 | github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= 223 | github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= 224 | github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= 225 | github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= 226 | github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= 227 | github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= 228 | github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= 229 | github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= 230 | github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 231 | github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= 232 | github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= 233 | github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= 234 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= 235 | github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= 236 | github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= 237 | github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= 238 | github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= 239 | github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= 240 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 241 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 242 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 243 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 244 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 245 | github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= 246 | github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= 247 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 248 | github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= 249 | github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= 250 | github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= 251 | github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= 252 | github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= 253 | github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= 254 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 255 | github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 256 | github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= 257 | github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 258 | github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= 259 | github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= 260 | github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= 261 | github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= 262 | github.com/slack-go/slack v0.11.0 h1:sBBjQz8LY++6eeWhGJNZpRm5jvLRNnWBFZ/cAq58a6k= 263 | github.com/slack-go/slack v0.11.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= 264 | github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 265 | github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= 266 | github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= 267 | github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 268 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 269 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 270 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 271 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 272 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 273 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 274 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 275 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 276 | github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= 277 | github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= 278 | github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= 279 | github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= 280 | github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= 281 | github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= 282 | github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= 283 | github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= 284 | github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= 285 | github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= 286 | github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= 287 | github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= 288 | github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 289 | github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 290 | github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= 291 | github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= 292 | github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= 293 | github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= 294 | github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= 295 | github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= 296 | github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= 297 | go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= 298 | go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= 299 | go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= 300 | go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= 301 | go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= 302 | go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= 303 | go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= 304 | go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= 305 | go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= 306 | go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= 307 | golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 308 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 309 | golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 310 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 311 | golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 312 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 313 | golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 314 | golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 315 | golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 316 | golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 317 | golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 318 | golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= 319 | golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 320 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 321 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 322 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 323 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 324 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 325 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 326 | golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 327 | golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 328 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 329 | golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 330 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 331 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 332 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 333 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 334 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 335 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 336 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 337 | golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 338 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 339 | golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 340 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 341 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 342 | golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 343 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 344 | golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= 345 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= 346 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 347 | golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ= 348 | golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= 349 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 350 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 351 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 352 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 353 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 354 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 355 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 356 | golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 357 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 358 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 359 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 360 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 361 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 362 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 363 | golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 364 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 365 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 366 | golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 367 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 368 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 369 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 370 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 371 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 372 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 373 | golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 374 | golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 375 | golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 376 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 377 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 378 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 379 | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 380 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 381 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 382 | golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 383 | golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 384 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 385 | golang.org/x/sys v0.0.0-20220624220833-87e55d714810 h1:rHZQSjJdAI4Xf5Qzeh2bBc5YJIkPFVM6oDtMFYmgws0= 386 | golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 387 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 388 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 389 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 390 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 391 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 392 | golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 393 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 394 | golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= 395 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= 396 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 397 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 398 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 399 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 400 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 401 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 402 | golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 403 | golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 404 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 405 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 406 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 407 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 408 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 409 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 410 | google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 411 | google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 412 | google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= 413 | google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 414 | google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 415 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 416 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 417 | google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= 418 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 419 | google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 420 | google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f h1:hJ/Y5SqPXbarffmAsApliUlcvMU+wScNGfyop4bZm8o= 421 | google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= 422 | google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= 423 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 424 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 425 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= 426 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 427 | google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 428 | google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= 429 | google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 430 | google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= 431 | google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8= 432 | google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= 433 | google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= 434 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 435 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 436 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 437 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 438 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 439 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 440 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 441 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 442 | google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= 443 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 444 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 445 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 446 | google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 447 | google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= 448 | google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 449 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 450 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 451 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 452 | gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 453 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 454 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 455 | gopkg.in/djherbis/times.v1 v1.3.0 h1:uxMS4iMtH6Pwsxog094W0FYldiNnfY/xba00vq6C2+o= 456 | gopkg.in/djherbis/times.v1 v1.3.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8= 457 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 458 | gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= 459 | gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= 460 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 461 | gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 462 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 463 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 464 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 465 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 466 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 467 | gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 468 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 469 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 470 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 471 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 472 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" 6 | "github.com/jmatsu/terraform-provider-slack/slack" 7 | ) 8 | 9 | //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs 10 | 11 | var version string 12 | var commit string 13 | 14 | func main() { 15 | var debug bool 16 | 17 | flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") 18 | flag.Parse() 19 | 20 | plugin.Serve(&plugin.ServeOpts{ 21 | Debug: debug, 22 | ProviderAddr: "registry.terraform.io/jmatsu/slack", 23 | ProviderFunc: slack.New(version, commit)}) 24 | } 25 | -------------------------------------------------------------------------------- /slack/cache.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "encoding/json" 5 | "gopkg.in/djherbis/times.v1" 6 | "io/ioutil" 7 | "os" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | const cacheDir = "./.terraform/plugins/.cache/terraform-provider-slack" 13 | 14 | func saveCacheAsJson(name string, v interface{}) { 15 | _ = os.MkdirAll(cacheDir, 0755) 16 | cacheFile := strings.Join([]string{cacheDir, name}, string(os.PathSeparator)) 17 | 18 | if cache, err := json.Marshal(v); err == nil { 19 | _ = ioutil.WriteFile(cacheFile, cache, 0644) 20 | } // ignore err 21 | } 22 | 23 | func restoreJsonCache(name string, v interface{}) bool { 24 | _ = os.MkdirAll(cacheDir, 0755) 25 | cacheFile := strings.Join([]string{cacheDir, name}, string(os.PathSeparator)) 26 | 27 | // cache active duration is 6 sec (10 req / min) 28 | if t, err := times.Stat(cacheFile); err == nil { 29 | if !time.Now().After(t.ModTime().Add(6 * time.Second)) { 30 | if bytes, err := ioutil.ReadFile(cacheFile); err == nil { 31 | return json.Unmarshal(bytes, v) == nil 32 | } 33 | } 34 | } 35 | 36 | return false 37 | } 38 | -------------------------------------------------------------------------------- /slack/config.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "github.com/slack-go/slack" 5 | ) 6 | 7 | type Config struct { 8 | Token string 9 | } 10 | 11 | type Team struct { 12 | client *slack.Client 13 | logger *Logger 14 | } 15 | 16 | func (c *Config) ProviderContext(version string, commit string) (*Team, error) { 17 | var team Team 18 | 19 | team.client = slack.New(c.Token) 20 | team.logger = configureLogger(version, commit) 21 | 22 | return &team, nil 23 | } 24 | -------------------------------------------------------------------------------- /slack/config_test.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import "testing" 4 | 5 | func Test_Client(t *testing.T) { 6 | config := &Config{ 7 | Token: "test token", 8 | } 9 | 10 | team, err := config.ProviderContext("version", "commit") 11 | 12 | if err != nil { 13 | t.Fatal(err) 14 | } 15 | 16 | if team.client == nil { 17 | t.Fatalf("required non-nil client") 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /slack/data_conversation.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | ) 9 | 10 | func dataSourceConversation() *schema.Resource { 11 | return &schema.Resource{ 12 | ReadContext: dataSlackConversationRead, 13 | 14 | Schema: map[string]*schema.Schema{ 15 | "channel_id": { 16 | Type: schema.TypeString, 17 | Required: true, 18 | }, 19 | "name": { 20 | Type: schema.TypeString, 21 | Computed: true, 22 | }, 23 | "topic": { 24 | Type: schema.TypeString, 25 | Computed: true, 26 | Optional: true, 27 | }, 28 | "purpose": { 29 | Type: schema.TypeString, 30 | Computed: true, 31 | Optional: true, 32 | }, 33 | "is_private": { 34 | Type: schema.TypeBool, 35 | Computed: true, 36 | }, 37 | "is_archived": { 38 | Type: schema.TypeBool, 39 | Computed: true, 40 | }, 41 | "is_shared": { 42 | Type: schema.TypeBool, 43 | Computed: true, 44 | }, 45 | "is_ext_shared": { 46 | Type: schema.TypeBool, 47 | Computed: true, 48 | }, 49 | "is_org_shared": { 50 | Type: schema.TypeBool, 51 | Computed: true, 52 | }, 53 | "created": { 54 | Type: schema.TypeInt, 55 | Computed: true, 56 | }, 57 | "creator": { 58 | Type: schema.TypeString, 59 | Computed: true, 60 | }, 61 | }, 62 | } 63 | } 64 | 65 | func dataSlackConversationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 66 | client := meta.(*Team).client 67 | conversationId := d.Get("channel_id").(string) 68 | 69 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 70 | "data": "conversation", 71 | "conversation_id": conversationId, 72 | }) 73 | 74 | logger.trace(ctx, "Start reading a conversation") 75 | 76 | channel, err := client.GetConversationInfoContext(ctx, conversationId, false) 77 | 78 | if err != nil { 79 | return diag.Diagnostics{ 80 | { 81 | Severity: diag.Error, 82 | Summary: fmt.Sprintf("Slack provider couldn't read conversation %s due to *%s*", conversationId, err.Error()), 83 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.info"), 84 | }, 85 | } 86 | } else { 87 | logger.trace(ctx, "Got a response from Slack api") 88 | } 89 | 90 | d.SetId(channel.ID) 91 | _ = d.Set("name", channel.Name) 92 | _ = d.Set("topic", channel.Topic.Value) 93 | _ = d.Set("purpose", channel.Purpose.Value) 94 | _ = d.Set("is_private", channel.IsPrivate) 95 | _ = d.Set("is_archived", channel.IsArchived) 96 | _ = d.Set("is_shared", channel.IsShared) 97 | _ = d.Set("is_ext_shared", channel.IsExtShared) 98 | _ = d.Set("is_org_shared", channel.IsOrgShared) 99 | _ = d.Set("created", channel.Created) 100 | _ = d.Set("creator", channel.Creator) 101 | 102 | logger.debug(ctx, "Conversation #%s (isArchived = %t)", d.Get("name").(string), d.Get("is_archived").(bool)) 103 | 104 | return nil 105 | } 106 | -------------------------------------------------------------------------------- /slack/data_user.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | "github.com/slack-go/slack" 9 | ) 10 | 11 | const ( 12 | userListCacheFileName = "users.json" 13 | userQueryTypeID = "id" 14 | userQueryTypeName = "name" 15 | userQueryTypeEmail = "email" 16 | ) 17 | 18 | func dataSourceSlackUser() *schema.Resource { 19 | return &schema.Resource{ 20 | ReadContext: dataSourceSlackUserRead, 21 | 22 | Schema: map[string]*schema.Schema{ 23 | "query_type": { 24 | Type: schema.TypeString, 25 | Required: true, 26 | ValidateDiagFunc: validateEnums([]string{userQueryTypeID, userQueryTypeName, userQueryTypeEmail}), 27 | }, 28 | "query_value": { 29 | Type: schema.TypeString, 30 | Required: true, 31 | }, 32 | "name": { 33 | Type: schema.TypeString, 34 | Computed: true, 35 | }, 36 | "real_name": { 37 | Type: schema.TypeString, 38 | Computed: true, 39 | }, 40 | "is_admin": { 41 | Type: schema.TypeBool, 42 | Computed: true, 43 | }, 44 | "is_owner": { 45 | Type: schema.TypeBool, 46 | Computed: true, 47 | }, 48 | "is_bot": { 49 | Type: schema.TypeBool, 50 | Computed: true, 51 | }, 52 | "has_2fa": { 53 | Type: schema.TypeBool, 54 | Computed: true, 55 | }, 56 | }, 57 | } 58 | } 59 | 60 | func dataSourceSlackUserRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 61 | queryType := d.Get("query_type").(string) 62 | queryValue := d.Get("query_value").(string) 63 | 64 | client := meta.(*Team).client 65 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 66 | "data": "slack_user", 67 | "query_type": queryType, 68 | "query_value": queryValue, 69 | }) 70 | 71 | configureUserFunc := func(d *schema.ResourceData, user slack.User) { 72 | d.SetId(user.ID) 73 | _ = d.Set("name", user.Name) 74 | _ = d.Set("real_name", user.RealName) 75 | _ = d.Set("is_admin", user.IsAdmin) 76 | _ = d.Set("is_owner", user.IsOwner) 77 | _ = d.Set("is_bot", user.IsBot) 78 | _ = d.Set("has_2fa", user.Has2FA) 79 | 80 | logger.debug(ctx, "User #%s (isBot = %t)", d.Get("name").(string), d.Get("is_bot").(bool)) 81 | } 82 | 83 | if queryType == userQueryTypeID { 84 | logger.trace(ctx, "Start reading the slack user by user_id") 85 | 86 | // https://api.slack.com/docs/rate-limits#tier_t4 87 | user, err := client.GetUserInfoContext(ctx, queryValue) 88 | 89 | if err != nil { 90 | return diag.Diagnostics{ 91 | { 92 | Severity: diag.Error, 93 | Summary: fmt.Sprintf("Slack provider couldn't find a slack user (%s) due to *%s*", queryValue, err.Error()), 94 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/users.info"), 95 | }, 96 | } 97 | } else { 98 | logger.trace(ctx, "Got a response from Slack api") 99 | } 100 | 101 | configureUserFunc(d, *user) 102 | return nil 103 | } 104 | 105 | if queryType == userQueryTypeEmail { 106 | logger.trace(ctx, "Start reading the slack user by email") 107 | 108 | // https://api.slack.com/methods/users.lookupByEmail 109 | // https://api.slack.com/docs/rate-limits#tier_t3 110 | user, err := client.GetUserByEmailContext(ctx, queryValue) 111 | 112 | if err != nil { 113 | return diag.Diagnostics{ 114 | { 115 | Severity: diag.Error, 116 | Summary: fmt.Sprintf("Slack provider couldn't find a slack user (%s) due to *%s*", queryValue, err.Error()), 117 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/users.lookupByEmail"), 118 | }, 119 | } 120 | } else { 121 | logger.trace(ctx, "Got a response from Slack api") 122 | } 123 | 124 | configureUserFunc(d, *user) 125 | return nil 126 | } 127 | 128 | if queryType == userQueryTypeName { 129 | logger.trace(ctx, "Start reading the slack user by user_name") 130 | 131 | // Use a cache for users api call because the limitation is stricter than user.info 132 | var users *[]slack.User 133 | 134 | if !restoreJsonCache(userListCacheFileName, &users) { 135 | tempUsers, err := client.GetUsersContext(ctx) 136 | 137 | if err != nil { 138 | return diag.Diagnostics{ 139 | { 140 | Severity: diag.Error, 141 | Summary: fmt.Sprintf("Slack provider couldn't find a slack user (%s) due to *%s*", queryValue, err.Error()), 142 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/users.list"), 143 | }, 144 | } 145 | } else { 146 | logger.trace(ctx, "Got a response from Slack api") 147 | } 148 | 149 | users = &tempUsers 150 | 151 | saveCacheAsJson(userListCacheFileName, &users) 152 | } 153 | 154 | if users == nil { 155 | return diag.Diagnostics{ 156 | { 157 | Severity: diag.Error, 158 | Summary: fmt.Sprintf("Serious error happened while finding a slack user (%s)", queryValue), 159 | Detail: "Please use another query_type or open an issue at https://github.com/jmatsu/terraform-provider-slack", 160 | }, 161 | } 162 | } 163 | 164 | for _, user := range *users { 165 | if dataSourceSlackUserMatch(&user, queryType, queryValue) { 166 | logger.debug(ctx, "Found a user") 167 | 168 | configureUserFunc(d, user) 169 | return nil 170 | } 171 | } 172 | 173 | return diag.Diagnostics{ 174 | { 175 | Severity: diag.Error, 176 | Summary: fmt.Sprintf("Slack provider couldn't find a slack user (%s)", queryValue), 177 | Detail: fmt.Sprintf("In general, slack username is not reliable and non-determistic. It's better to use %s or %s to look up a user instead and so we've deprecated this query type actually", userQueryTypeEmail, userQueryTypeID), 178 | }, 179 | } 180 | } 181 | 182 | logger.error(ctx, "this flow is an unexpected") 183 | 184 | return diag.Diagnostics{ 185 | { 186 | Severity: diag.Error, 187 | Summary: fmt.Sprintf("%s in query_type is not acceptable", queryType), 188 | Detail: fmt.Sprintf("Either one of %s, %s and %s is allowed", userQueryTypeID, userQueryTypeEmail, userQueryTypeID), 189 | }, 190 | } 191 | } 192 | 193 | func dataSourceSlackUserMatch(user *slack.User, queryType string, queryValue string) bool { 194 | switch queryType { 195 | case userQueryTypeName: 196 | return user.Name == queryValue || user.RealName == queryValue || user.Profile.DisplayName == queryValue 197 | case userQueryTypeEmail: 198 | return user.Profile.Email == queryValue 199 | case userQueryTypeID: 200 | return user.ID == queryValue 201 | } 202 | return false 203 | } 204 | -------------------------------------------------------------------------------- /slack/data_usergroup.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | "github.com/slack-go/slack" 9 | ) 10 | 11 | func dataSourceUserGroup() *schema.Resource { 12 | return &schema.Resource{ 13 | ReadContext: dataSlackUserGroupRead, 14 | 15 | Schema: map[string]*schema.Schema{ 16 | "usergroup_id": { 17 | Type: schema.TypeString, 18 | Required: true, 19 | }, 20 | "handle": { 21 | Type: schema.TypeString, 22 | Computed: true, 23 | }, 24 | "name": { 25 | Type: schema.TypeString, 26 | Computed: true, 27 | }, 28 | "description": { 29 | Type: schema.TypeString, 30 | Computed: true, 31 | Optional: true, 32 | }, 33 | "auto_type": { 34 | Type: schema.TypeString, 35 | Computed: true, 36 | }, 37 | "team_id": { 38 | Type: schema.TypeString, 39 | Computed: true, 40 | }, 41 | }, 42 | } 43 | } 44 | 45 | func dataSlackUserGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 46 | usergroupId := d.Get("usergroup_id").(string) 47 | 48 | client := meta.(*Team).client 49 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 50 | "data": "slack_usergroup", 51 | "usergroup_id": usergroupId, 52 | }) 53 | 54 | logger.trace(ctx, "Start reading a usergroup") 55 | 56 | groups, err := client.GetUserGroupsContext(ctx, func(params *slack.GetUserGroupsParams) { 57 | params.IncludeUsers = false 58 | params.IncludeCount = false 59 | params.IncludeDisabled = true 60 | }) 61 | 62 | if err != nil { 63 | return diag.Diagnostics{ 64 | { 65 | Severity: diag.Error, 66 | Summary: fmt.Sprintf("provicer cannot find a usergroup (%s) due to *%s*", usergroupId, err.Error()), 67 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.list"), 68 | }, 69 | } 70 | } else { 71 | logger.trace(ctx, "Got a response from Slack api") 72 | } 73 | 74 | for _, group := range groups { 75 | if group.ID == usergroupId { 76 | d.SetId(group.ID) 77 | _ = d.Set("handle", group.Handle) 78 | _ = d.Set("name", group.Name) 79 | _ = d.Set("description", group.Description) 80 | _ = d.Set("auto_type", group.AutoType) 81 | _ = d.Set("team_id", group.TeamID) 82 | 83 | logger.debug(ctx, "UserGroup @%s", d.Get("handle").(string)) 84 | return nil 85 | } 86 | } 87 | 88 | return diag.Diagnostics{ 89 | { 90 | Severity: diag.Error, 91 | Summary: fmt.Sprintf("provicer cannot find a usergroup (%s)", usergroupId), 92 | Detail: fmt.Sprintf("a usergroup (%s) is not found in available usergroups that this token can view", usergroupId), 93 | }, 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /slack/logger.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-log/tflog" 7 | "reflect" 8 | "strings" 9 | ) 10 | 11 | func configureLogger(version string, commit string) *Logger { 12 | return &Logger{ 13 | tags: map[string]interface{}{ 14 | "provider": "jmatsu/slack", 15 | "version": version, 16 | "commit": commit, 17 | }, 18 | delegation: nil, 19 | } 20 | } 21 | 22 | type Logger struct { 23 | tags map[string]interface{} 24 | delegation *Logger 25 | } 26 | 27 | func (logger *Logger) lift(ctx context.Context, level string, message string, tags ...map[string]interface{}) { 28 | if reflect.ValueOf(logger).IsNil() { 29 | switch strings.ToLower(level) { 30 | case "trace": 31 | tflog.Trace(ctx, message, tags...) 32 | case "debug": 33 | tflog.Debug(ctx, message, tags...) 34 | case "info": 35 | tflog.Info(ctx, message, tags...) 36 | case "warn": 37 | tflog.Warn(ctx, message, tags...) 38 | case "error": 39 | tflog.Error(ctx, message, tags...) 40 | } 41 | return 42 | } 43 | 44 | logger.delegation.lift(ctx, level, message, append(tags, logger.tags)...) 45 | } 46 | 47 | func (logger *Logger) withTags(tags map[string]interface{}) *Logger { 48 | return &Logger{ 49 | tags: tags, 50 | delegation: logger, 51 | } 52 | } 53 | 54 | func (logger *Logger) trace(ctx context.Context, format string, v ...interface{}) { 55 | logger.lift(ctx, "trace", fmt.Sprintf(format, v...)) 56 | } 57 | 58 | func (logger *Logger) debug(ctx context.Context, format string, v ...interface{}) { 59 | logger.lift(ctx, "debug", fmt.Sprintf(format, v...)) 60 | } 61 | 62 | func (logger *Logger) info(ctx context.Context, format string, v ...interface{}) { 63 | logger.lift(ctx, "info", fmt.Sprintf(format, v...)) 64 | } 65 | 66 | func (logger *Logger) warning(ctx context.Context, format string, v ...interface{}) { 67 | logger.lift(ctx, "warn", fmt.Sprintf(format, v...)) 68 | } 69 | 70 | func (logger *Logger) error(ctx context.Context, format string, v ...interface{}) { 71 | logger.lift(ctx, "error", fmt.Sprintf(format, v...)) 72 | } 73 | -------------------------------------------------------------------------------- /slack/provider.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 7 | ) 8 | 9 | var descriptions map[string]string 10 | 11 | func init() { 12 | descriptions = map[string]string{ 13 | "token": "The OAuth token used to connect to Slack.", 14 | } 15 | 16 | schema.DescriptionKind = schema.StringMarkdown 17 | } 18 | 19 | func New(version string, commit string) func() *schema.Provider { 20 | return func() *schema.Provider { 21 | p := &schema.Provider{ 22 | Schema: map[string]*schema.Schema{ 23 | "token": { 24 | Type: schema.TypeString, 25 | Required: true, 26 | DefaultFunc: schema.EnvDefaultFunc("SLACK_TOKEN", nil), 27 | Description: descriptions["token"], 28 | }, 29 | }, 30 | 31 | DataSourcesMap: map[string]*schema.Resource{ 32 | "slack_user": dataSourceSlackUser(), 33 | "slack_usergroup": dataSourceUserGroup(), 34 | "slack_conversation": dataSourceConversation(), 35 | }, 36 | 37 | ResourcesMap: map[string]*schema.Resource{ 38 | "slack_usergroup": resourceSlackUserGroup(), 39 | "slack_usergroup_members": resourceSlackUserGroupMembers(), 40 | "slack_conversation": resourceSlackConversation(), 41 | "slack_usergroup_channels": resourceSlackUserGroupChannels(), 42 | }, 43 | } 44 | 45 | p.ConfigureContextFunc = configureProvider(version, commit) 46 | 47 | return p 48 | } 49 | } 50 | 51 | func configureProvider(version string, commit string) schema.ConfigureContextFunc { 52 | return func(context context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { 53 | config := Config{ 54 | Token: d.Get("token").(string), 55 | } 56 | 57 | meta, err := config.ProviderContext(version, commit) 58 | 59 | if err != nil { 60 | return nil, diag.Diagnostics{ 61 | { 62 | Severity: diag.Error, 63 | Summary: "Cannot create a Slack client in set up", 64 | Detail: err.Error(), 65 | }, 66 | } 67 | } 68 | 69 | return meta, nil 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /slack/resource_conversation.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" 9 | "github.com/slack-go/slack" 10 | ) 11 | 12 | const ( 13 | conversationActionOnDestroyNone = "none" 14 | conversationActionOnDestroyArchive = "archive" 15 | ) 16 | 17 | var validateConversationActionOnDestroyValue = validation.StringInSlice([]string{ 18 | conversationActionOnDestroyNone, 19 | conversationActionOnDestroyArchive, 20 | }, false) 21 | 22 | func resourceSlackConversation() *schema.Resource { 23 | return &schema.Resource{ 24 | ReadContext: resourceSlackConversationRead, 25 | CreateContext: resourceSlackConversationCreate, 26 | UpdateContext: resourceSlackConversationUpdate, 27 | DeleteContext: resourceSlackConversationDelete, 28 | 29 | Importer: &schema.ResourceImporter{ 30 | StateContext: schema.ImportStatePassthroughContext, 31 | }, 32 | 33 | Schema: map[string]*schema.Schema{ 34 | "name": { 35 | Type: schema.TypeString, 36 | Required: true, 37 | }, 38 | "is_private": { 39 | Type: schema.TypeBool, 40 | Required: true, 41 | }, 42 | "topic": { 43 | Type: schema.TypeString, 44 | Optional: true, 45 | }, 46 | "purpose": { 47 | Type: schema.TypeString, 48 | Optional: true, 49 | }, 50 | "is_archived": { 51 | Type: schema.TypeBool, 52 | Optional: true, 53 | Default: false, 54 | }, 55 | "action_on_destroy": { 56 | Type: schema.TypeString, 57 | Description: "Either of none or archive", 58 | Required: true, 59 | ValidateFunc: validateConversationActionOnDestroyValue, 60 | }, 61 | "is_shared": { 62 | Type: schema.TypeBool, 63 | Computed: true, 64 | }, 65 | "is_ext_shared": { 66 | Type: schema.TypeBool, 67 | Computed: true, 68 | }, 69 | "is_org_shared": { 70 | Type: schema.TypeBool, 71 | Computed: true, 72 | }, 73 | "created": { 74 | Type: schema.TypeInt, 75 | Computed: true, 76 | }, 77 | "creator": { 78 | Type: schema.TypeString, 79 | Computed: true, 80 | }, 81 | }, 82 | } 83 | } 84 | 85 | func configureSlackConversation(ctx context.Context, logger *Logger, d *schema.ResourceData, channel *slack.Channel) { 86 | d.SetId(channel.ID) 87 | _ = d.Set("name", channel.Name) 88 | _ = d.Set("topic", channel.Topic.Value) 89 | _ = d.Set("purpose", channel.Purpose.Value) 90 | _ = d.Set("is_archived", channel.IsArchived) 91 | _ = d.Set("is_shared", channel.IsShared) 92 | _ = d.Set("is_ext_shared", channel.IsExtShared) 93 | _ = d.Set("is_org_shared", channel.IsOrgShared) 94 | _ = d.Set("created", channel.Created) 95 | _ = d.Set("creator", channel.Creator) 96 | 97 | // Required 98 | _ = d.Set("is_private", channel.IsPrivate) 99 | 100 | // Never support 101 | //_ = d.Set("members", channel.Members) 102 | //_ = d.Set("num_members", channel.NumMembers) 103 | //_ = d.Set("unread_count", channel.UnreadCount) 104 | //_ = d.Set("unread_count_display", channel.UnreadCountDisplay) 105 | //_ = d.Set("last_read", channel.Name) 106 | //_ = d.Set("latest", channel.Name) 107 | 108 | logger.debug(ctx, "Configured Conversation #%s (isArchived = %t)", d.Id(), d.Get("is_archived").(bool)) 109 | } 110 | 111 | func resourceSlackConversationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 112 | name := d.Get("name").(string) 113 | isPrivate := d.Get("is_private").(bool) 114 | 115 | client := meta.(*Team).client 116 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 117 | "resource": "slack_conversation", 118 | "conversation_name": name, 119 | "is_private": isPrivate, 120 | }) 121 | 122 | logger.trace(ctx, "Start creating a conversation") 123 | 124 | channel, err := client.CreateConversationContext(ctx, name, isPrivate) 125 | 126 | if err != nil { 127 | return diag.Diagnostics{ 128 | { 129 | Severity: diag.Error, 130 | Summary: fmt.Sprintf("Slack provider couldn't create a slack conversation (%s, isPrivate = %t) due to *%s*", name, isPrivate, err.Error()), 131 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.create"), 132 | }, 133 | } 134 | } else { 135 | logger.trace(ctx, "Got a response from Slack API") 136 | } 137 | 138 | configureSlackConversation(ctx, logger, d, channel) 139 | 140 | return nil 141 | } 142 | 143 | func resourceSlackConversationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 144 | id := d.Id() 145 | 146 | client := meta.(*Team).client 147 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 148 | "resource": "slack_conversation", 149 | "conversation_id": id, 150 | }) 151 | 152 | logger.trace(ctx, "Start reading the conversation") 153 | 154 | channel, err := client.GetConversationInfoContext(ctx, id, false) 155 | 156 | if err != nil { 157 | return diag.Diagnostics{ 158 | { 159 | Severity: diag.Error, 160 | Summary: fmt.Sprintf("Slack provider couldn't find a slack conversation (%s) due to *%s*", id, err.Error()), 161 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.info"), 162 | }, 163 | } 164 | } else { 165 | logger.trace(ctx, "Got a response from Slack API") 166 | } 167 | 168 | configureSlackConversation(ctx, logger, d, channel) 169 | 170 | return nil 171 | } 172 | 173 | func resourceSlackConversationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 174 | id := d.Id() 175 | 176 | client := meta.(*Team).client 177 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 178 | "resource": "slack_conversation", 179 | "conversation_id": id, 180 | }) 181 | 182 | // TODO check if it's changed or not to reduce api calls 183 | 184 | name := d.Get("name").(string) 185 | 186 | if _, err := client.RenameConversationContext(ctx, id, name); err != nil { 187 | return diag.Diagnostics{ 188 | { 189 | Severity: diag.Error, 190 | Summary: fmt.Sprintf("Slack provider couldn't rename a slack conversation (%s) to %s due to *%s*", id, name, err.Error()), 191 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.rename"), 192 | }, 193 | } 194 | } else { 195 | logger.trace(ctx, "Renamed the conversation to %s", name) 196 | } 197 | 198 | if topic, ok := d.GetOk("topic"); ok { 199 | if _, err := client.SetTopicOfConversationContext(ctx, id, topic.(string)); err != nil { 200 | return diag.Diagnostics{ 201 | { 202 | Severity: diag.Error, 203 | Summary: fmt.Sprintf("Slack provider couldn't set a topic of a slack conversation (%s) to %s due to *%s*", id, topic.(string), err.Error()), 204 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.setTopic"), 205 | }, 206 | } 207 | } 208 | } else { 209 | logger.trace(ctx, "Set the conversation topic to %s", topic) 210 | } 211 | 212 | if purpose, ok := d.GetOk("purpose"); ok { 213 | if _, err := client.SetPurposeOfConversationContext(ctx, id, purpose.(string)); err != nil { 214 | return diag.Diagnostics{ 215 | { 216 | Severity: diag.Error, 217 | Summary: fmt.Sprintf("Slack provider couldn't set a purpose of a slack conversation (%s) to %s due to *%s*", id, purpose.(string), err.Error()), 218 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.setPurpose"), 219 | }, 220 | } 221 | } 222 | } 223 | 224 | if isArchived, ok := d.GetOkExists("is_archived"); ok { 225 | if isArchived.(bool) { 226 | if err := client.ArchiveConversationContext(ctx, id); err != nil { 227 | if err.Error() != "already_archived" { 228 | return diag.Diagnostics{ 229 | { 230 | Severity: diag.Error, 231 | Summary: fmt.Sprintf("Slack provider couldn't archive a slack conversation (%s) due to *%s*", id, err.Error()), 232 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.archive"), 233 | }, 234 | } 235 | } else { 236 | logger.debug(ctx, "The conversation has already been archived") 237 | } 238 | } 239 | 240 | logger.trace(ctx, "Archived the conversation") 241 | } else { 242 | if err := client.UnArchiveConversationContext(ctx, id); err != nil { 243 | if err.Error() != "not_archived" { 244 | return diag.Diagnostics{ 245 | { 246 | Severity: diag.Error, 247 | Summary: fmt.Sprintf("Slack provider couldn't unarchive a slack conversation (%s) due to *%s*", id, err.Error()), 248 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.unarchive"), 249 | }, 250 | } 251 | } else { 252 | logger.debug(ctx, "The conversation has already been unarchived") 253 | } 254 | } 255 | 256 | logger.trace(ctx, "Unarchived the conversation") 257 | } 258 | } 259 | 260 | return resourceSlackConversationRead(ctx, d, meta) 261 | } 262 | 263 | func resourceSlackConversationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 264 | id := d.Id() 265 | 266 | client := meta.(*Team).client 267 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 268 | "resource": "slack_conversation", 269 | "conversation_id": id, 270 | }) 271 | 272 | action := d.Get("action_on_destroy").(string) 273 | 274 | switch action { 275 | case conversationActionOnDestroyNone: 276 | logger.debug(ctx, "Does nothing on destroy") 277 | case conversationActionOnDestroyArchive: 278 | logger.debug(ctx, "Archive the conversation (%s) on destroy", d.Get("name").(string)) 279 | 280 | if err := client.ArchiveConversationContext(ctx, id); err != nil { 281 | if err.Error() != "already_archived" { 282 | return diag.Diagnostics{ 283 | { 284 | Severity: diag.Error, 285 | Summary: fmt.Sprintf("Slack provider couldn't archive a slack conversation (%s) due to *%s*", id, err.Error()), 286 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/conversations.archive"), 287 | }, 288 | } 289 | } else { 290 | logger.debug(ctx, "The conversation has already been archived") 291 | } 292 | } 293 | 294 | logger.trace(ctx, "Archived the conversation") 295 | default: 296 | return diag.Diagnostics{ 297 | { 298 | Severity: diag.Error, 299 | Summary: fmt.Sprintf("%s in action_on_destroy is not acceptable", action), 300 | Detail: fmt.Sprintf("Either one of %s and %s is allowed", conversationActionOnDestroyNone, conversationActionOnDestroyArchive), 301 | }, 302 | } 303 | } 304 | 305 | d.SetId("") 306 | 307 | logger.debug(ctx, "Cleared the resource id of this conversation so it's going to be removed from the state") 308 | 309 | return nil 310 | } 311 | -------------------------------------------------------------------------------- /slack/resource_usergroup.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | "github.com/slack-go/slack" 9 | ) 10 | 11 | const userGroupListCacheFileName = "usergroups.json" 12 | 13 | func resourceSlackUserGroup() *schema.Resource { 14 | return &schema.Resource{ 15 | ReadContext: resourceSlackUserGroupRead, 16 | CreateContext: resourceSlackUserGroupCreate, 17 | UpdateContext: resourceSlackUserGroupUpdate, 18 | DeleteContext: resourceSlackUserGroupDelete, 19 | 20 | Importer: &schema.ResourceImporter{ 21 | StateContext: schema.ImportStatePassthroughContext, 22 | }, 23 | 24 | Schema: map[string]*schema.Schema{ 25 | "handle": { 26 | Type: schema.TypeString, 27 | Required: true, 28 | }, 29 | "name": { 30 | Type: schema.TypeString, 31 | Optional: true, 32 | }, 33 | "description": { 34 | Type: schema.TypeString, 35 | Optional: true, 36 | }, 37 | "auto_type": { 38 | Type: schema.TypeString, 39 | Optional: true, 40 | Default: "", 41 | ValidateDiagFunc: validateEnums([]string{"admins", "owners", ""}), 42 | }, 43 | "team_id": { 44 | Type: schema.TypeString, 45 | Computed: true, 46 | }, 47 | }, 48 | } 49 | } 50 | 51 | func configureSlackUserGroup(ctx context.Context, logger *Logger, d *schema.ResourceData, userGroup slack.UserGroup) { 52 | d.SetId(userGroup.ID) 53 | _ = d.Set("handle", userGroup.Handle) 54 | _ = d.Set("name", userGroup.Name) 55 | _ = d.Set("description", userGroup.Description) 56 | _ = d.Set("auto_type", userGroup.AutoType) 57 | _ = d.Set("team_id", userGroup.TeamID) 58 | 59 | logger.debug(ctx, "Configured UserGroup #%s @%s", d.Id(), d.Get("handle").(string)) 60 | } 61 | 62 | func resourceSlackUserGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 63 | handle := d.Get("handle").(string) 64 | 65 | client := meta.(*Team).client 66 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 67 | "resource": "slack_conversation", 68 | "usergroup_handle": handle, 69 | }) 70 | 71 | logger.debug(ctx, "Start creating a usergroup") 72 | 73 | var name = handle 74 | 75 | if value, ok := d.GetOk("name"); ok { 76 | logger.debug(ctx, "usergroup name (%s) is specified", value.(string)) 77 | name = value.(string) 78 | } 79 | 80 | newUserGroup := &slack.UserGroup{ 81 | Handle: handle, 82 | Name: name, 83 | Description: d.Get("description").(string), 84 | AutoType: d.Get("auto_type").(string), 85 | } 86 | 87 | userGroup, err := client.CreateUserGroupContext(ctx, *newUserGroup) 88 | 89 | if err != nil { 90 | return diag.Diagnostics{ 91 | { 92 | Severity: diag.Error, 93 | Summary: fmt.Sprintf("Slack provider couldn't create a slack usergroup (%s) due to *%s*", handle, err.Error()), 94 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.create"), 95 | }, 96 | } 97 | } else { 98 | logger.trace(ctx, "Got a response from Slack API") 99 | } 100 | 101 | configureSlackUserGroup(ctx, logger, d, userGroup) 102 | 103 | return nil 104 | } 105 | 106 | func resourceSlackUserGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 107 | id := d.Id() 108 | 109 | client := meta.(*Team).client 110 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 111 | "resource": "slack_conversation", 112 | "usergroup_id": id, 113 | }) 114 | 115 | logger.trace(ctx, "Start reading a usergroup") 116 | 117 | // Use a cache for usergroups api call because the limitation is strict 118 | var userGroups *[]slack.UserGroup 119 | 120 | if !restoreJsonCache(userGroupListCacheFileName, &userGroups) { 121 | tempUserGroups, err := client.GetUserGroupsContext(ctx, func(params *slack.GetUserGroupsParams) { 122 | params.IncludeUsers = false 123 | params.IncludeCount = false 124 | params.IncludeDisabled = true 125 | }) 126 | 127 | if err != nil { 128 | return diag.Diagnostics{ 129 | { 130 | Severity: diag.Error, 131 | Summary: fmt.Sprintf("Slack provider couldn't find slack usergroups due to *%s*", err.Error()), 132 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.list"), 133 | }, 134 | } 135 | } else { 136 | logger.trace(ctx, "Got a response from Slack API") 137 | } 138 | 139 | userGroups = &tempUserGroups 140 | 141 | saveCacheAsJson(userGroupListCacheFileName, &userGroups) 142 | } else { 143 | logger.trace(ctx, "Read usergroups from the cahed") 144 | } 145 | 146 | for _, userGroup := range *userGroups { 147 | if userGroup.ID == id { 148 | configureSlackUserGroup(ctx, logger, d, userGroup) 149 | return nil 150 | } 151 | } 152 | 153 | return diag.Diagnostics{ 154 | { 155 | Severity: diag.Error, 156 | Summary: fmt.Sprintf("Slack provider couldn't find a slack usergroup (%s)", id), 157 | Detail: fmt.Sprintf("a usergroup (%s) is not found in this workspace", id), 158 | }, 159 | } 160 | } 161 | 162 | func resourceSlackUserGroupUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 163 | id := d.Id() 164 | 165 | client := meta.(*Team).client 166 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 167 | "resource": "slack_conversation", 168 | "usergroup_id": id, 169 | }) 170 | 171 | logger.trace(ctx, "Start updating the usergroup") 172 | 173 | handle := d.Get("handle").(string) 174 | var name = handle 175 | 176 | if value, ok := d.GetOk("name"); ok { 177 | logger.debug(ctx, "name (%s) is specified", value.(string)) 178 | name = value.(string) 179 | } 180 | 181 | editedUserGroup := &slack.UserGroup{ 182 | ID: id, 183 | Handle: handle, 184 | Name: name, 185 | Description: d.Get("description").(string), 186 | AutoType: d.Get("auto_type").(string), 187 | } 188 | 189 | userGroup, err := client.UpdateUserGroupContext(ctx, *editedUserGroup) 190 | 191 | if err != nil { 192 | return diag.Diagnostics{ 193 | { 194 | Severity: diag.Error, 195 | Summary: fmt.Sprintf("Slack provider couldn't update the slack usergroup (%s) due to *%s*", id, err.Error()), 196 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.update"), 197 | }, 198 | } 199 | } else { 200 | logger.trace(ctx, "Got a response from Slack API") 201 | } 202 | 203 | configureSlackUserGroup(ctx, logger, d, userGroup) 204 | return nil 205 | } 206 | 207 | func resourceSlackUserGroupDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 208 | id := d.Id() 209 | 210 | client := meta.(*Team).client 211 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 212 | "resource": "slack_conversation", 213 | "usergroup_id": id, 214 | }) 215 | 216 | logger.trace(ctx, "Start deleting (actually disabling) usergroup") 217 | 218 | if _, err := client.DisableUserGroupContext(ctx, id); err != nil { 219 | if err.Error() != "already_disabled" { 220 | return diag.Diagnostics{ 221 | { 222 | Severity: diag.Error, 223 | Summary: fmt.Sprintf("Slack provider couldn't disable the slack usergroup (%s) due to *%s*", id, err.Error()), 224 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.disable"), 225 | }, 226 | } 227 | } else { 228 | logger.debug(ctx, "This usergroup has already been disabled") 229 | } 230 | } else { 231 | logger.trace(ctx, "Got a response from Slack API") 232 | } 233 | 234 | d.SetId("") 235 | 236 | logger.debug(ctx, "Cleared the resource id of this usergroup so it's going to be removed from the state") 237 | 238 | return nil 239 | } 240 | -------------------------------------------------------------------------------- /slack/resource_usergroup_channels.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | "github.com/slack-go/slack" 9 | ) 10 | 11 | func resourceSlackUserGroupChannels() *schema.Resource { 12 | return &schema.Resource{ 13 | ReadContext: resourceSlackUserGroupChannelsRead, 14 | CreateContext: resourceSlackUserGroupChannelsCreate, 15 | UpdateContext: resourceSlackUserGroupChannelsUpdate, 16 | DeleteContext: resourceSlackUserGroupChannelsDelete, 17 | 18 | Importer: &schema.ResourceImporter{ 19 | StateContext: func(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { 20 | _ = d.Set("usergroup_id", d.Id()) 21 | return schema.ImportStatePassthroughContext(ctx, d, m) 22 | }, 23 | }, 24 | 25 | Schema: map[string]*schema.Schema{ 26 | "usergroup_id": { 27 | Type: schema.TypeString, 28 | Required: true, 29 | }, 30 | "channels": { 31 | Type: schema.TypeSet, 32 | Elem: &schema.Schema{ 33 | Type: schema.TypeString, 34 | }, 35 | Required: true, 36 | }, 37 | }, 38 | } 39 | } 40 | 41 | func configureSlackUserGroupChannels(ctx context.Context, logger *Logger, d *schema.ResourceData, userGroup slack.UserGroup) { 42 | d.SetId(userGroup.ID) 43 | _ = d.Set("channels", append(userGroup.Prefs.Channels, userGroup.Prefs.Groups...)) 44 | 45 | logger.debug(ctx, "Configured usergroups' default channels") 46 | } 47 | 48 | func resourceSlackUserGroupChannelsCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 49 | usergroupId := d.Get("usergroup_id").(string) 50 | 51 | client := meta.(*Team).client 52 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 53 | "resource": "slack_usergroup_channels", 54 | "usergroup_id": usergroupId, 55 | }) 56 | 57 | logger.trace(ctx, "Start creating the default channels") 58 | 59 | iChannels := d.Get("channels").(*schema.Set).List() 60 | channelsIds := make([]string, len(iChannels)) 61 | for i, v := range iChannels { 62 | channelsIds[i] = v.(string) 63 | } 64 | 65 | params := &slack.UserGroup{ 66 | ID: usergroupId, 67 | Prefs: slack.UserGroupPrefs{ 68 | Channels: channelsIds, 69 | }, 70 | } 71 | 72 | userGroup, err := client.UpdateUserGroupContext(ctx, *params) 73 | 74 | if err != nil { 75 | return diag.Diagnostics{ 76 | { 77 | Severity: diag.Error, 78 | Summary: fmt.Sprintf("Slack provider couldn't add the default channels to the slack usergroup (%s)", usergroupId), 79 | Detail: err.Error(), 80 | }, 81 | } 82 | } 83 | 84 | configureSlackUserGroupChannels(ctx, logger, d, userGroup) 85 | 86 | return nil 87 | } 88 | 89 | func resourceSlackUserGroupChannelsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 90 | currentId := d.Id() 91 | 92 | client := meta.(*Team).client 93 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 94 | "resource": "slack_usergroup_channels", 95 | "usergroup_id": currentId, 96 | }) 97 | 98 | usergroupId := d.Get("usergroup_id").(string) 99 | 100 | logger.trace(ctx, "Start reading default channels of the usergroup") 101 | 102 | if usergroupId != d.Id() { 103 | return diag.Diagnostics{ 104 | { 105 | Severity: diag.Error, 106 | Summary: fmt.Sprintf("it's not allowed to change usergroup id (from %s to %s)", currentId, usergroupId), 107 | Detail: "Please move the state or create another resource instead", 108 | }, 109 | } 110 | } 111 | 112 | // Use a cache for usergroups api call because the limitation is strict 113 | var userGroups *[]slack.UserGroup 114 | 115 | if !restoreJsonCache(userGroupListCacheFileName, &userGroups) { 116 | tempUserGroups, err := client.GetUserGroupsContext(ctx, func(params *slack.GetUserGroupsParams) { 117 | params.IncludeUsers = false 118 | params.IncludeCount = false 119 | params.IncludeDisabled = true 120 | }) 121 | 122 | if err != nil { 123 | return diag.Diagnostics{ 124 | { 125 | Severity: diag.Error, 126 | Summary: fmt.Sprintf("Slack provider couldn't read the default channels of the slack usergroup (%s) due to *%s*", usergroupId, err.Error()), 127 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.list"), 128 | }, 129 | } 130 | } else { 131 | logger.trace(ctx, "Got a response from Slack API") 132 | } 133 | 134 | userGroups = &tempUserGroups 135 | 136 | saveCacheAsJson(userGroupListCacheFileName, &userGroups) 137 | } 138 | 139 | if userGroups == nil { 140 | return diag.Diagnostics{ 141 | { 142 | Severity: diag.Error, 143 | Summary: fmt.Sprintf("Serious error happened while reading default channles of the slack usergroup (%s)", usergroupId), 144 | Detail: "Internal provider error. Please open an issue at https://github.com/jmatsu/terraform-provider-slack", 145 | }, 146 | } 147 | } 148 | 149 | for _, userGroup := range *userGroups { 150 | if userGroup.ID == usergroupId { 151 | configureSlackUserGroupChannels(ctx, logger, d, userGroup) 152 | return nil 153 | } 154 | } 155 | 156 | return nil 157 | } 158 | 159 | func resourceSlackUserGroupChannelsUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 160 | currentId := d.Id() 161 | 162 | client := meta.(*Team).client 163 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 164 | "resource": "slack_usergroup_channels", 165 | "usergroup_id": currentId, 166 | }) 167 | 168 | logger.trace(ctx, "Start updating default channels of the usergroup") 169 | 170 | usergroupId := d.Get("usergroup_id").(string) 171 | 172 | if usergroupId != d.Id() { 173 | return diag.Diagnostics{ 174 | { 175 | Severity: diag.Error, 176 | Summary: fmt.Sprintf("it's not allowed to change usergroup id (from %s to %s)", currentId, usergroupId), 177 | Detail: "Please move the state or create another resource instead", 178 | }, 179 | } 180 | } 181 | 182 | iChannels := d.Get("channels").(*schema.Set).List() 183 | channelsIds := make([]string, len(iChannels)) 184 | for i, v := range iChannels { 185 | channelsIds[i] = v.(string) 186 | } 187 | 188 | params := &slack.UserGroup{ 189 | ID: usergroupId, 190 | Prefs: slack.UserGroupPrefs{ 191 | Channels: channelsIds, 192 | }, 193 | } 194 | 195 | userGroup, err := client.UpdateUserGroupContext(ctx, *params) 196 | 197 | if err != nil { 198 | return diag.Diagnostics{ 199 | { 200 | Severity: diag.Error, 201 | Summary: fmt.Sprintf("Slack provider couldn't update the default channels of the slack usergroup (%s) due to *%s*", usergroupId, err.Error()), 202 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.update"), 203 | }, 204 | } 205 | } 206 | 207 | configureSlackUserGroupChannels(ctx, logger, d, userGroup) 208 | 209 | return nil 210 | } 211 | 212 | func resourceSlackUserGroupChannelsDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 213 | currentId := d.Id() 214 | 215 | client := meta.(*Team).client 216 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 217 | "resource": "slack_usergroup_channels", 218 | "usergroup_id": currentId, 219 | }) 220 | 221 | logger.trace(ctx, "Start destroying default channels of the usergroup") 222 | 223 | usergroupId := d.Get("usergroup_id").(string) 224 | 225 | if usergroupId != currentId { 226 | return diag.Diagnostics{ 227 | { 228 | Severity: diag.Error, 229 | Summary: fmt.Sprintf("it's not allowed to change usergroup id (from %s to %s)", currentId, usergroupId), 230 | Detail: "Please move the state or create another resource instead", 231 | }, 232 | } 233 | } 234 | 235 | params := &slack.UserGroup{ 236 | ID: usergroupId, 237 | Prefs: slack.UserGroupPrefs{ 238 | Channels: []string{}, 239 | }, 240 | } 241 | 242 | // 0 default channels are allowed by spec 243 | if _, err := client.UpdateUserGroupContext(ctx, *params); err != nil { 244 | return diag.Diagnostics{ 245 | { 246 | Severity: diag.Error, 247 | Summary: fmt.Sprintf("Slack provider couldn't remove all default channels from the slack usergroup (%s) due to *%s*", usergroupId, err.Error()), 248 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.update"), 249 | }, 250 | } 251 | } 252 | 253 | d.SetId("") 254 | 255 | logger.debug(ctx, "Cleared the resource id of this usergourps' default channels resource so it's going to be removed from the state") 256 | 257 | return nil 258 | } 259 | -------------------------------------------------------------------------------- /slack/resource_usergroup_members.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | "github.com/slack-go/slack" 9 | "strings" 10 | ) 11 | 12 | func resourceSlackUserGroupMembers() *schema.Resource { 13 | return &schema.Resource{ 14 | ReadContext: resourceSlackUserGroupMembersRead, 15 | CreateContext: resourceSlackUserGroupMembersCreate, 16 | UpdateContext: resourceSlackUserGroupMembersUpdate, 17 | DeleteContext: resourceSlackUserGroupMembersDelete, 18 | 19 | Importer: &schema.ResourceImporter{ 20 | StateContext: func(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { 21 | _ = d.Set("usergroup_id", d.Id()) 22 | return schema.ImportStatePassthroughContext(ctx, d, m) 23 | }, 24 | }, 25 | 26 | Schema: map[string]*schema.Schema{ 27 | "usergroup_id": { 28 | Type: schema.TypeString, 29 | Required: true, 30 | }, 31 | "members": { 32 | Type: schema.TypeSet, 33 | Elem: &schema.Schema{ 34 | Type: schema.TypeString, 35 | }, 36 | Required: true, 37 | }, 38 | }, 39 | } 40 | } 41 | 42 | func configureSlackUserGroupMembers(ctx context.Context, logger *Logger, d *schema.ResourceData, userGroup slack.UserGroup) { 43 | d.SetId(userGroup.ID) 44 | _ = d.Set("members", userGroup.Users) 45 | 46 | logger.debug(ctx, "Configured channel members") 47 | } 48 | 49 | func resourceSlackUserGroupMembersCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 50 | usergroupId := d.Get("usergroup_id").(string) 51 | 52 | client := meta.(*Team).client 53 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 54 | "resource": "slack_usergroup_channels", 55 | "usergroup_id": usergroupId, 56 | }) 57 | 58 | logger.trace(ctx, "Start creating members of the usergroup") 59 | 60 | iMembers := d.Get("members").(*schema.Set) 61 | userIds := make([]string, len(iMembers.List())) 62 | for i, v := range iMembers.List() { 63 | userIds[i] = v.(string) 64 | } 65 | userIdParam := strings.Join(userIds, ",") 66 | 67 | userGroup, err := client.UpdateUserGroupMembersContext(ctx, usergroupId, userIdParam) 68 | 69 | if err != nil { 70 | return diag.Diagnostics{ 71 | { 72 | Severity: diag.Error, 73 | Summary: fmt.Sprintf("Slack provider couldn't attach members of the slack usergroup (%s) due to *%s*", usergroupId, err.Error()), 74 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.users.update"), 75 | }, 76 | } 77 | } 78 | 79 | configureSlackUserGroupMembers(ctx, logger, d, userGroup) 80 | 81 | return nil 82 | } 83 | 84 | func resourceSlackUserGroupMembersRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 85 | currentId := d.Id() 86 | 87 | client := meta.(*Team).client 88 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 89 | "resource": "slack_usergroup_channels", 90 | "usergroup_id": currentId, 91 | }) 92 | 93 | logger.trace(ctx, "Start reading the usergroup members") 94 | 95 | usergroupId := d.Get("usergroup_id").(string) 96 | 97 | if usergroupId != d.Id() { 98 | return diag.Diagnostics{ 99 | { 100 | Severity: diag.Error, 101 | Summary: fmt.Sprintf("it's not allowed to change usergroup id (from %s to %s)", currentId, usergroupId), 102 | Detail: "Please move the state or create another resource instead", 103 | }, 104 | } 105 | } 106 | 107 | members, err := client.GetUserGroupMembersContext(ctx, usergroupId) 108 | 109 | if err != nil { 110 | return diag.Diagnostics{ 111 | { 112 | Severity: diag.Error, 113 | Summary: fmt.Sprintf("Slack provider couldn't read members of the slack usergroup (%s) due to *%s*", usergroupId, err.Error()), 114 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.users.list"), 115 | }, 116 | } 117 | } 118 | 119 | _ = d.Set("members", members) 120 | 121 | logger.debug(ctx, "Configured members of the usergroup") 122 | 123 | return nil 124 | } 125 | 126 | func resourceSlackUserGroupMembersUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 127 | currentId := d.Id() 128 | 129 | client := meta.(*Team).client 130 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 131 | "resource": "slack_usergroup_channels", 132 | "usergroup_id": currentId, 133 | }) 134 | 135 | logger.trace(ctx, "Start updating members of the usergroup") 136 | 137 | usergroupId := d.Get("usergroup_id").(string) 138 | 139 | if usergroupId != d.Id() { 140 | return diag.Diagnostics{ 141 | { 142 | Severity: diag.Error, 143 | Summary: fmt.Sprintf("it's not allowed to change usergroup id (from %s to %s)", currentId, usergroupId), 144 | Detail: "Please move the state or create another resource instead", 145 | }, 146 | } 147 | } 148 | 149 | logger.debug(ctx, "Enable the usergroup first because disabled usergroups reject updates") 150 | _, err := client.EnableUserGroupContext(ctx, usergroupId) 151 | 152 | if err != nil && err.Error() != "already_enabled" { 153 | return diag.Diagnostics{ 154 | { 155 | Severity: diag.Error, 156 | Summary: fmt.Sprintf("Slack provider couldn't activate the slack usergroup (%s) to update members due to *%s*", usergroupId, err.Error()), 157 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.enable"), 158 | }, 159 | } 160 | } 161 | 162 | iMembers := d.Get("members").(*schema.Set) 163 | userIds := make([]string, len(iMembers.List())) 164 | for i, v := range iMembers.List() { 165 | userIds[i] = v.(string) 166 | } 167 | userIdParam := strings.Join(userIds, ",") 168 | 169 | userGroup, err := client.UpdateUserGroupMembersContext(ctx, usergroupId, userIdParam) 170 | 171 | if err != nil { 172 | return diag.Diagnostics{ 173 | { 174 | Severity: diag.Error, 175 | Summary: fmt.Sprintf("Slack provider couldn't update members of the slack usergroup (%s) due to *%s*", usergroupId, err.Error()), 176 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.users.update"), 177 | }, 178 | } 179 | } 180 | 181 | configureSlackUserGroupMembers(ctx, logger, d, userGroup) 182 | 183 | return nil 184 | } 185 | 186 | func resourceSlackUserGroupMembersDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 187 | currentId := d.Id() 188 | 189 | client := meta.(*Team).client 190 | logger := meta.(*Team).logger.withTags(map[string]interface{}{ 191 | "resource": "slack_usergroup_channels", 192 | "usergroup_id": currentId, 193 | }) 194 | 195 | logger.trace(ctx, "Start destroying members of the usergroup") 196 | 197 | usergroupId := d.Get("usergroup_id").(string) 198 | 199 | if usergroupId != d.Id() { 200 | return diag.Diagnostics{ 201 | { 202 | Severity: diag.Error, 203 | Summary: fmt.Sprintf("it's not allowed to change usergroup id (from %s to %s)", currentId, usergroupId), 204 | Detail: "Please move the state or create another resource instead", 205 | }, 206 | } 207 | } 208 | 209 | logger.debug(ctx, "A usergroup that has no members cannot be created by web API so just disable it") 210 | 211 | // Cannot use "" as a member parameter, so let me disable it 212 | if _, err := client.DisableUserGroupContext(ctx, usergroupId); err != nil { 213 | return diag.Diagnostics{ 214 | { 215 | Severity: diag.Error, 216 | Summary: fmt.Sprintf("Slack provider couldn't disable the slack usergroup (%s) due to *%s*", usergroupId, err.Error()), 217 | Detail: fmt.Sprintf("Please refer to %s for the details.", "https://api.slack.com/methods/usergroups.disable"), 218 | }, 219 | } 220 | } 221 | 222 | d.SetId("") 223 | 224 | logger.debug(ctx, "Cleared the resource id of this usergroup members' resource so it's going to be removed from the state") 225 | 226 | return nil 227 | } 228 | -------------------------------------------------------------------------------- /slack/resource_usergroup_members_test.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 5 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 6 | "github.com/slack-go/slack" 7 | "testing" 8 | ) 9 | 10 | func stringInSlice(slice []string, val string) bool { 11 | for _, item := range slice { 12 | if item == val { 13 | return true 14 | } 15 | } 16 | return false 17 | } 18 | 19 | type userGroupResponse struct { 20 | slack.SlackResponse 21 | UserGroup slack.UserGroup `json:"usergroup"` 22 | } 23 | 24 | type userGroupUsersListResponse struct { 25 | slack.SlackResponse 26 | Users []string `json:"users"` 27 | } 28 | 29 | var testUserGroup = slack.UserGroup{ 30 | ID: "S0615G0KT", 31 | Users: []string{"U0614TZR7", "U060RNRCZ"}, 32 | } 33 | 34 | func Test_ResourceUserGroupMembersRead(t *testing.T) { 35 | d := resourceSlackUserGroupMembers().TestResourceData() 36 | ctx, team := createTestTeam(t, Routes{ 37 | { 38 | Path: "/usergroups.users.list", 39 | Response: userGroupUsersListResponse{ 40 | slack.SlackResponse{Ok: true}, 41 | testUserGroup.Users, 42 | }, 43 | }, 44 | }) 45 | 46 | if diags := resourceSlackUserGroupMembersRead(ctx, d, team); diags.HasError() { 47 | for _, d := range diags { 48 | if d.Severity == diag.Error { 49 | t.Fatalf("err: %s", d.Summary) 50 | } 51 | } 52 | } 53 | 54 | members := d.Get("members").(*schema.Set) 55 | if len(testUserGroup.Users) != members.Len() { 56 | t.Fatalf("expect %v members but got %v", len(testUserGroup.Users), members.Len()) 57 | } 58 | for _, m := range members.List() { 59 | if !stringInSlice(testUserGroup.Users, m.(string)) { 60 | t.Fatalf("unexpected user ID %s", m) 61 | } 62 | } 63 | } 64 | 65 | func Test_ResourceUserGroupMembersCreate(t *testing.T) { 66 | d := resourceSlackUserGroupMembers().TestResourceData() 67 | 68 | newMembers := &schema.Set{F: schema.HashString} 69 | for _, u := range testUserGroup.Users { 70 | newMembers.Add(u) 71 | } 72 | if err := d.Set("members", newMembers); err != nil { 73 | t.Fatalf("err setting existing members: %s", err) 74 | } 75 | 76 | ctx, team := createTestTeam(t, Routes{ 77 | { 78 | Path: "/usergroups.users.update", 79 | Response: userGroupResponse{ 80 | slack.SlackResponse{Ok: true}, 81 | testUserGroup, 82 | }, 83 | }, 84 | }) 85 | 86 | if diags := resourceSlackUserGroupMembersCreate(ctx, d, team); diags.HasError() { 87 | for _, d := range diags { 88 | if d.Severity == diag.Error { 89 | t.Fatalf("err: %s", d.Summary) 90 | } 91 | } 92 | } 93 | 94 | members := d.Get("members").(*schema.Set) 95 | if len(testUserGroup.Users) != members.Len() { 96 | t.Fatalf("expect %v members but got %v", len(testUserGroup.Users), members.Len()) 97 | } 98 | for _, m := range members.List() { 99 | if !stringInSlice(testUserGroup.Users, m.(string)) { 100 | t.Fatalf("unexpected user ID %s", m) 101 | } 102 | } 103 | } 104 | 105 | func Test_ResourceUserGroupMembersUpdate(t *testing.T) { 106 | d := resourceSlackUserGroupMembers().TestResourceData() 107 | d.SetId(testUserGroup.ID) 108 | if err := d.Set("usergroup_id", testUserGroup.ID); err != nil { 109 | t.Fatalf("err set usergroup_id: %s", err) 110 | } 111 | existingMembers := &schema.Set{F: schema.HashString} 112 | for _, u := range testUserGroup.Users { 113 | existingMembers.Add(u) 114 | } 115 | if err := d.Set("members", existingMembers); err != nil { 116 | t.Fatalf("err setting existing members: %s", err) 117 | } 118 | 119 | newTestUserGroup := testUserGroup 120 | newTestUserGroup.Users = append(newTestUserGroup.Users, "NUSERID") 121 | 122 | ctx, team := createTestTeam(t, Routes{ 123 | { 124 | Path: "/usergroups.enable", 125 | Response: slack.SlackResponse{Ok: true}, 126 | }, 127 | { 128 | Path: "/usergroups.users.update", 129 | Response: userGroupResponse{ 130 | slack.SlackResponse{Ok: true}, 131 | newTestUserGroup, 132 | }, 133 | }, 134 | }) 135 | 136 | if diags := resourceSlackUserGroupMembersUpdate(ctx, d, team); diags.HasError() { 137 | for _, d := range diags { 138 | if d.Severity == diag.Error { 139 | t.Fatalf("err: %s", d.Summary) 140 | } 141 | } 142 | } 143 | 144 | members := d.Get("members").(*schema.Set) 145 | if len(newTestUserGroup.Users) != members.Len() { 146 | t.Fatalf("expect %v members but got %v", len(newTestUserGroup.Users), members.Len()) 147 | } 148 | for _, m := range members.List() { 149 | if !stringInSlice(newTestUserGroup.Users, m.(string)) { 150 | t.Fatalf("unexpected user ID %s", m) 151 | } 152 | } 153 | } 154 | 155 | func Test_ResourceUserGroupMembersDelete(t *testing.T) { 156 | d := resourceSlackUserGroupMembers().TestResourceData() 157 | d.SetId(testUserGroup.ID) 158 | if err := d.Set("usergroup_id", testUserGroup.ID); err != nil { 159 | t.Fatalf("err set usergroup_id: %s", err) 160 | } 161 | 162 | ctx, team := createTestTeam(t, Routes{ 163 | { 164 | Path: "/usergroups.disable", 165 | Response: userGroupResponse{ 166 | slack.SlackResponse{Ok: true}, 167 | testUserGroup, 168 | }, 169 | }, 170 | }) 171 | 172 | if diags := resourceSlackUserGroupMembersDelete(ctx, d, team); diags.HasError() { 173 | for _, d := range diags { 174 | if d.Severity == diag.Error { 175 | t.Fatalf("err: %s", d.Summary) 176 | } 177 | } 178 | } 179 | 180 | if d.Id() != "" { 181 | t.Fatalf("expect id to be empty, but got %s", d.Id()) 182 | } 183 | 184 | } 185 | -------------------------------------------------------------------------------- /slack/server_test.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/slack-go/slack" 7 | "net/http" 8 | "net/http/httptest" 9 | "testing" 10 | ) 11 | 12 | type Routes = []Route 13 | 14 | type Route struct { 15 | Path string 16 | Response interface{} 17 | } 18 | 19 | func createTestTeam(t *testing.T, routes Routes) (context.Context, *Team) { 20 | m := http.NewServeMux() 21 | 22 | for _, route := range routes { 23 | m.HandleFunc(route.Path, func(w http.ResponseWriter, r *http.Request) { 24 | renderJson(w, route.Response) 25 | }) 26 | } 27 | 28 | ts := httptest.NewServer(m) 29 | 30 | client := slack.New("test_token", 31 | slack.Option(slack.OptionHTTPClient(ts.Client())), 32 | slack.OptionAPIURL(ts.URL+"/")) 33 | 34 | ctx, cancelFunc := context.WithCancel(context.Background()) 35 | 36 | t.Cleanup(func() { 37 | cancelFunc() 38 | ts.Close() 39 | }) 40 | 41 | return ctx, &Team{ 42 | client: client, 43 | } 44 | } 45 | 46 | func renderJson(w http.ResponseWriter, response interface{}) { 47 | w.Header().Set("Content-Type", "application/json") 48 | b, _ := json.Marshal(response) 49 | w.Write(b) 50 | } 51 | -------------------------------------------------------------------------------- /slack/util.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "fmt" 5 | "github.com/hashicorp/go-cty/cty" 6 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 8 | ) 9 | 10 | func validateEnums(values []string) schema.SchemaValidateDiagFunc { 11 | return func(v interface{}, path cty.Path) diag.Diagnostics { 12 | if !containsAny(values, v.(string)) { 13 | return diag.Diagnostics{ 14 | { 15 | Severity: diag.Error, 16 | Summary: fmt.Sprintf("%s is an invalid value for argument %s", v.(string), path), 17 | Detail: "", 18 | }, 19 | } 20 | } 21 | 22 | return nil 23 | } 24 | } 25 | 26 | func containsAny(values []string, any string) bool { 27 | valid := false 28 | 29 | for _, value := range values { 30 | if value == any { 31 | valid = true 32 | break 33 | } 34 | } 35 | 36 | return valid 37 | } 38 | -------------------------------------------------------------------------------- /slack/util_test.go: -------------------------------------------------------------------------------- 1 | package slack 2 | 3 | import ( 4 | "github.com/hashicorp/go-cty/cty" 5 | "testing" 6 | ) 7 | 8 | func Test_validateEnums(t *testing.T) { 9 | 10 | cases := []struct { 11 | Value string 12 | ExpectErrCount int 13 | }{ 14 | { 15 | Value: "foo", 16 | ExpectErrCount: 0, 17 | }, 18 | { 19 | Value: "bar", 20 | ExpectErrCount: 0, 21 | }, 22 | { 23 | Value: "baz", 24 | ExpectErrCount: 0, 25 | }, 26 | { 27 | Value: "none", 28 | ExpectErrCount: 1, 29 | }, 30 | } 31 | 32 | validationFunc := validateEnums([]string{"foo", "bar", "baz"}) 33 | 34 | for _, tc := range cases { 35 | diag := validationFunc(tc.Value, cty.Path{}) 36 | 37 | if len(diag) != tc.ExpectErrCount { 38 | t.Fatalf("Expected 1 validation error but %d", tc.ExpectErrCount) 39 | } 40 | } 41 | } 42 | 43 | func Test_containsAny(t *testing.T) { 44 | slices := []string{"foo", "bar", "baz"} 45 | 46 | cases := []struct { 47 | Value string 48 | Expect bool 49 | }{ 50 | { 51 | Value: "foo", 52 | Expect: true, 53 | }, 54 | { 55 | Value: "bar", 56 | Expect: true, 57 | }, 58 | { 59 | Value: "baz", 60 | Expect: true, 61 | }, 62 | { 63 | Value: "none", 64 | Expect: false, 65 | }, 66 | } 67 | 68 | for _, tc := range cases { 69 | actual := containsAny(slices, tc.Value) 70 | 71 | if actual != tc.Expect { 72 | t.Fatalf("Expected %t but %t", tc.Expect, actual) 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /tools/download-provider: -------------------------------------------------------------------------------- 1 | ./src/download-provider.bash -------------------------------------------------------------------------------- /tools/src/download-provider.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | 5 | readonly RELEASE_URL="https://github.com/jmatsu/terraform-provider-slack/releases" 6 | 7 | die() { 8 | echo "$@" 1>&2 9 | exit 1 10 | } 11 | 12 | mktemp() { 13 | command mktemp 2>/dev/null || command mktemp -t tmp 14 | } 15 | 16 | last_version() { 17 | curl -sL -o /dev/null -w %{url_effective} "$RELEASE_URL/latest" | 18 | rev | 19 | cut -f1 -d'/'| 20 | rev 21 | } 22 | 23 | is_windows() { 24 | [[ "$(uname -s)" == "Windows" ]] 25 | } 26 | 27 | download() { 28 | local -r version="$1" temp_file="$TEMP_FILE" 29 | 30 | if is_windows; then 31 | curl -sL -o "$temp_file" \ 32 | "$RELEASE_URL/download/$VERSION/terraform-provider-slack_$(uname -s)_$(uname -m).zip" 33 | else 34 | curl -sL -o "$temp_file" \ 35 | "$RELEASE_URL/download/$VERSION/terraform-provider-slack_$(uname -s)_$(uname -m).tar.gz" 36 | fi 37 | } 38 | 39 | : "${VERSION:=$(last_version)}" 40 | 41 | if [[ -z "$VERSION" ]]; then 42 | die "Unable to get version. Please retry with VERSION=" 43 | fi 44 | 45 | readonly TEMP_FILE=$(mktemp) 46 | readonly TEMP_DIR=$(command mktemp -d) 47 | 48 | trap "rm ${TEMP_FILE} || : ; rm -fr ${TEMP_DIR} || : ; exit 1" 1 2 3 15 49 | 50 | download "$VERSION" 51 | 52 | mkdir -p "$TEMP_DIR" 53 | 54 | if is_windows; then 55 | unzip -d "$TEMP_DIR" "$TEMP_FILE" 56 | else 57 | tar -xf "$TEMP_FILE" -C "$TEMP_DIR" 58 | fi 59 | 60 | cp "$TEMP_DIR/terraform-provider-slack" ./terraform-provider-slack_${VERSION} 61 | 62 | rm -fr "$TEMP_DIR" -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | package tools 5 | 6 | import ( 7 | // document generation 8 | _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" 9 | ) 10 | --------------------------------------------------------------------------------