Skip to content

Commit

Permalink
init.rb: throw if a team is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbatm committed Mar 5, 2024
1 parent c37cea5 commit a306839
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tofu/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ def tf!(*args)
id_name = name_to_tf(name)

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

f.puts(<<~EOM)
import {
id = "#{id}"
to = github_team.#{id_name}
}
EOM

f.puts(<<~EOM) if has_members
import {
id = "#{id}"
to = github_team_members.#{id_name}
Expand All @@ -99,6 +100,6 @@ def tf!(*args)

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

File.delete("generated.tf")
File.delete("generated.tf") if File.exists?("generated.tf")

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

0 comments on commit a306839

Please sign in to comment.