Skip to content

Commit a306839

Browse files
committed
init.rb: throw if a team is empty
1 parent c37cea5 commit a306839

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tofu/init.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,16 @@ def tf!(*args)
8080
id_name = name_to_tf(name)
8181

8282
has_members = gh(:api, "/orgs/#{ORG}/team/#{id}/members?per_page=1").any?
83+
if not has_members then
84+
throw "NO MEMBERS, delete this team: #{name}"
85+
end
8386

8487
f.puts(<<~EOM)
8588
import {
8689
id = "#{id}"
8790
to = github_team.#{id_name}
8891
}
89-
EOM
90-
91-
f.puts(<<~EOM) if has_members
92+
9293
import {
9394
id = "#{id}"
9495
to = github_team_members.#{id_name}
@@ -99,6 +100,6 @@ def tf!(*args)
99100

100101
### Import the resources in the terraform state and generate the terraform resources
101102

102-
File.delete("generated.tf")
103+
File.delete("generated.tf") if File.exists?("generated.tf")
103104

104105
tf!(:plan, "-generate-config-out=generated.tf")

0 commit comments

Comments
 (0)