Skip to content

Commit 7234e96

Browse files
MoteHueAlex-Welsh
authored andcommitted
Move terraform-bastion to the Admins team
1 parent f0b5823 commit 7234e96

4 files changed

Lines changed: 53 additions & 15 deletions

File tree

ansible/inventory/group_vars/all/source-repositories

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ ansible_workflows:
2626
- publish-role
2727
community_files:
2828
codeowners:
29+
admins: |
30+
* @stackhpc/admins
2931
ansible: |
3032
* @stackhpc/ansible
3133
batch: |
@@ -412,6 +414,14 @@ source_repositories:
412414
- codeowners:
413415
content: "{{ community_files.codeowners.openstack }}"
414416
dest: ".github/CODEOWNERS"
417+
# Admins team
418+
terraform-bastion:
419+
repository_type: "single-branch"
420+
workflows: []
421+
community_files:
422+
- codeowners:
423+
content: "{{ community_files.codeowners.admins }}"
424+
dest: ".github/CODEOWNERS"
415425
# Ansible team
416426
ansible-role-libvirt-host:
417427
repository_type: "ansible"
@@ -735,10 +745,3 @@ source_repositories:
735745
- codeowners:
736746
content: "{{ community_files.codeowners.sms_lab }}"
737747
dest: ".github/CODEOWNERS"
738-
terraform-bastion:
739-
repository_type: "single-branch"
740-
workflows: []
741-
community_files:
742-
- codeowners:
743-
content: "{{ community_files.codeowners.sms_lab }}"
744-
dest: ".github/CODEOWNERS"

scripts/validate-source-repos.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ def _extract_group_from_community_files(files):
3838
return content.strip('{ }').replace('_', '').split('.')[-1]
3939

4040

41-
def _sort_ans_repos_by_group(ans_repos):
41+
def _group_ans_repos_by_group(ans_repos):
4242
ans_repos_by_group = {}
4343
for repo in ans_repos:
44-
files = ans_repos[repo]['community_files']
45-
group = _extract_group_from_community_files(files)
44+
group = _extract_group_from_community_files(
45+
ans_repos[repo]['community_files'])
4646
if group in ans_repos_by_group:
4747
ans_repos_by_group[group].append(repo)
4848
else:
@@ -51,7 +51,7 @@ def _sort_ans_repos_by_group(ans_repos):
5151

5252

5353
def get_mismatched_repos(tf_repos, ans_repos, repos_missing):
54-
ans_repos_new = _sort_ans_repos_by_group(ans_repos)
54+
ans_repos_new = _group_ans_repos_by_group(ans_repos)
5555
tf_repos_new = {k.lower(): v for k, v in tf_repos.items()}
5656

5757
mismatched_repos = []
@@ -77,10 +77,11 @@ def main():
7777
repos_missing)
7878

7979
print('The following repos are assigned to different codeowner groups in '
80-
'the Ansible source-repositories and the Terraform tfvars: '
81-
f'{mismatched_repos}')
80+
'the Ansible source-repositories and the Terraform tfvars: '
81+
f'{mismatched_repos}')
8282

8383
return len(repos_missing) > 0 or len(mismatched_repos) > 0
8484

85+
8586
if __name__ == "__main__":
8687
sys.exit(main())

terraform/github/branches.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
resource "github_branch_protection" "admins_branch_protection" {
2+
for_each = toset(var.repositories["Admins"])
3+
repository_id = data.github_repository.repositories[each.key].node_id
4+
5+
pattern = "master"
6+
require_conversation_resolution = true
7+
allows_deletions = false
8+
allows_force_pushes = false
9+
10+
required_pull_request_reviews {
11+
dismiss_stale_reviews = true
12+
require_code_owner_reviews = true
13+
required_approving_review_count = 1
14+
}
15+
16+
restrict_pushes {
17+
blocks_creations = false
18+
push_allowances = [
19+
resource.github_team.organisation_teams["Developers"].node_id
20+
]
21+
}
22+
23+
required_status_checks {
24+
contexts = lookup(var.required_status_checks, each.key, { "default" : [] }).default
25+
strict = false
26+
}
27+
28+
lifecycle {
29+
prevent_destroy = true
30+
}
31+
}
32+
133
resource "github_branch_protection" "ansible_branch_protection" {
234
for_each = toset(var.repositories["Ansible"])
335
repository_id = data.github_repository.repositories[each.key].node_id

terraform/github/terraform.tfvars.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"owner": "stackhpc",
33
"repositories": {
4+
"Admins": [
5+
"terraform-bastion"
6+
],
47
"Ansible": [
58
"ansible-role-libvirt-host",
69
"ansible-role-libvirt-vm",
@@ -89,8 +92,7 @@
8992
"SMSLab": [
9093
"smslab-azimuth-config",
9194
"smslab-config",
92-
"smslab-kayobe-config",
93-
"terraform-bastion"
95+
"smslab-kayobe-config"
9496
]
9597
},
9698
"teams": {

0 commit comments

Comments
 (0)