-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5b3468
commit c90504e
Showing
6 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
terraform { | ||
required_providers { | ||
slack = { | ||
source = "pablovarela/slack" | ||
version = "~> 1.0" | ||
} | ||
} | ||
} | ||
|
||
variable "data_sources" { | ||
default = { | ||
tsc_members_user_ids = [] | ||
maintainers_user_ids = [] | ||
repo_maintainers = {} | ||
} | ||
description = "Data sources for the slack channels from the users module" | ||
} | ||
|
||
locals { | ||
channel_data = yamldecode(file("${path.module}/channels.yaml")) | ||
channels = { | ||
for channel in local.channel_data : channel.name => { | ||
name = channel.name | ||
topic = channel.topic | ||
purpose = channel.purpose | ||
|
||
# if permanent_members is not provided, then it wil be taken from local with the name in data sources | ||
permanent_members = lookup(channel, "permanent_members", lookup(var.data_sources, lookup(channel, "data_source", channel.name), [])) | ||
is_private = channel.is_private | ||
action_on_destroy = channel.action_on_destroy | ||
|
||
# if private channel, then kick all users on update else none | ||
action_on_update_permanent_members = channel.is_private ? "kick" : "none" | ||
adopt_existing_channel = true | ||
} | ||
} | ||
} | ||
|
||
resource "slack_conversation" "channels" { | ||
for_each = local.channels | ||
name = each.value.name | ||
topic = each.value.topic | ||
purpose = each.value.purpose | ||
permanent_members = each.value.permanent_members | ||
|
||
is_private = each.value.is_private | ||
action_on_destroy = each.value.action_on_destroy | ||
action_on_update_permanent_members = each.value.action_on_update_permanent_members | ||
adopt_existing_channel = each.value.adopt_existing_channel | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
- name: channel_1 | ||
topic: both members. | ||
purpose: test channel_1. | ||
is_private: false | ||
is_archived: false | ||
action_on_destroy: archive | ||
permanent_members: | ||
- "U08A1GT9AP7" | ||
- "U08A4BEKM50" | ||
|
||
- name: channel_2 | ||
topic: single member. | ||
purpose: test channel_2. | ||
is_private: false | ||
is_archived: false | ||
action_on_destroy: archive | ||
permanent_members: | ||
- "U08A1GT9AP7" | ||
|
||
- name: channel_3 | ||
topic: single member. | ||
purpose: test channel_3. | ||
is_private: false | ||
is_archived: false | ||
action_on_destroy: archive | ||
permanent_members: | ||
- "U08A4BEKM50" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
terraform { | ||
required_providers { | ||
slack = { | ||
source = "pablovarela/slack" | ||
version = "~> 1.0" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} | ||
|
||
variable "slack_token" { | ||
description = "The Slack API token with the channels:manage, channels:read, channels:write.invites, groups:read, groups:write, groups:write.invites, users:read scopes" | ||
nullable = false | ||
type = string | ||
} | ||
|
||
provider "slack" { | ||
token = var.slack_token | ||
} | ||
|
||
module "users" { | ||
source = "./users" | ||
} | ||
|
||
module "channels" { | ||
source = "./channels" | ||
depends_on = [ module.users ] | ||
data_sources = module.users.data_sources | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
terraform { | ||
required_providers { | ||
slack = { | ||
source = "pablovarela/slack" | ||
version = "~> 1.0" | ||
} | ||
} | ||
} | ||
|
||
locals { | ||
maintainers_data = yamldecode(file("${path.root}/../../../MAINTAINERS.yaml")) | ||
|
||
# maintainers with isTscMember = true are added to the tsc_members group | ||
tsc_members_data = [for maintainer in local.maintainers_data : maintainer if lookup(maintainer, "isTscMember", false) == true] | ||
|
||
# Make a map of repo maintainers with their slack user id with repo name as key | ||
repos = setunion(flatten([for maintainer in local.maintainers_data : maintainer.repos])) | ||
repo_maintainers = { | ||
for repo in local.repos : repo => | ||
[for maintainer in local.maintainers_data : maintainer.slack if contains(maintainer.repos, repo)] | ||
} | ||
} | ||
|
||
output "data_sources" { | ||
value = { | ||
maintainers_user_ids = [for maintainer in local.maintainers_data : maintainer.slack] | ||
tsc_members_user_ids = [for tsc_member in local.tsc_members_data : tsc_member.slack] | ||
repo_maintainers = local.repo_maintainers | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- name: Tushar Anand | ||
github: neoandmatrix | ||
linkedin: tushar-anand-neo | ||
slack: U08A4BEKM50 | ||
availableForHire: false | ||
isTscMember: true | ||
repos: | ||
- some-repo | ||
githubID: 141230066 | ||
|
||
- name: Other member | ||
github: no-github | ||
linkedin: no-linkedin | ||
slack: U08A1GT9AP7 | ||
availableForHire: false | ||
isTscMember: true | ||
repos: | ||
- some-repo | ||
githubID: 141230063 |