Skip to content

Commit

Permalink
🎉 Release HW0
Browse files Browse the repository at this point in the history
  • Loading branch information
joyliu-q committed Sep 10, 2024
1 parent 3024575 commit 382b9f8
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 81 deletions.
92 changes: 46 additions & 46 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions terraform/cert-manager-files/cert.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: ${NAME}-cis1880-org
name: ${NAME}-cis1912-org
spec:
secretName: ${NAME}-cis1880-org-tls
secretName: ${NAME}-cis1912-org-tls
dnsNames:
- "${NAME}.cis1880.org"
- "${NAME}.cis1912.org"
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
Expand Down
13 changes: 7 additions & 6 deletions terraform/github.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ module "hws" {
for hw in local.hws : "${hw.hw}-${hw.student}" => hw
if hw != "hw0" && hw != "hw1" && hw != "hw2"
}
source = "./modules/hw_repo"
hw = each.value.hw
pennkey = each.value.student
team-id = github_team.teams[each.value.student].id
bot-team-id = github_team.bot.id
published = each.value.published
source = "./modules/hw_repo"
hw = each.value.hw
pennkey = each.value.student
github-username = local.users[each.value.student]
team-id = github_team.teams[each.value.student].id
bot-team-id = github_team.bot.id
published = each.value.published
}
23 changes: 19 additions & 4 deletions terraform/github_bot.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ resource "github_repository" "hw" {
lifecycle {
prevent_destroy = true
}

template {
repository = each.key
owner = "cis1912"
}
}

// Grant bot user push access to hw repos
Expand All @@ -43,11 +48,21 @@ resource "github_team_membership" "bot" {
}
}

resource "github_team_repository" "bot" {
for_each = local.published
team_id = github_team.bot.id
resource "github_repository_collaborators" "bot" {
for_each = local.published

repository = each.key
permission = "push"

user {
permission = "admin"
username = local.bot_user
}

team {
permission = "push"
team_id = github_team.bot.id
}


lifecycle {
prevent_destroy = true
Expand Down
10 changes: 5 additions & 5 deletions terraform/helm/grafana.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ingress:
enabled: true
hosts:
- grafana.cis1880.org
- grafana.cis1912.org
tls:
- secretName: grafana-cis1880-org-tls
- secretName: grafana-cis1912-org-tls
hosts:
- grafana.cis1880.org
- grafana.cis1912.org

admin:
existingSecret: grafana
Expand Down Expand Up @@ -57,7 +57,7 @@ datasources:

grafana.ini:
server:
domain: "grafana.cis1880.org"
domain: "grafana.cis1912.org"
root_url: "https://%(domain)s/"
auth.github:
enabled: true
Expand All @@ -66,6 +66,6 @@ grafana.ini:
token_url: https://github.com/login/oauth/access_token
api_url: https://api.github.com/user
allow_sign_up: true
allowed_organizations: cis1880
allowed_organizations: cis1912

envFromSecret: "grafana"
6 changes: 3 additions & 3 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
// Name of the homework mapped to published status
published = {
hw0 = false
hw0 = true
hw1 = false
hw2 = false
hw3 = false
Expand All @@ -16,8 +16,8 @@ locals {
}
]
])
bot_user = "cis188bot"
k8s_cluster_name = "cis188"
bot_user = "cis1912bot"
k8s_cluster_name = "cis1912"
users = merge(var.students, var.instructors, var.tas)
emails = var.emails
}
26 changes: 16 additions & 10 deletions terraform/modules/hw_repo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ resource "github_repository" "hw" {
visibility = "private"

template {
owner = "cis1880"
owner = "cis1912"
repository = var.hw
}
}

resource "github_team_repository" "hw" {
resource "github_repository_collaborators" "hw" {
count = var.published ? 1 : 0
team_id = var.team-id
repository = github_repository.hw[0].name
permission = var.hw != "hw4" ? "push" : "admin"
}

resource "github_team_repository" "bot" {
count = var.published ? 1 : 0
team_id = var.bot-team-id
repository = github_repository.hw[0].name
permission = "admin"
user {
permission = "admin"
username = "cis1912bot"
}

team {
permission = var.hw != "hw4" ? "push" : "admin"
team_id = var.team-id
}

user {
permission = "push"
username = var.github-username
}
}
5 changes: 5 additions & 0 deletions terraform/modules/hw_repo/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ variable "pennkey" {
description = "Pennkey of student"
}

variable "github-username" {
type = string
description = "GitHub username of student"
}

variable "hw" {
type = string
description = "Homework to create repo of (Ex. hw0)."
Expand Down
3 changes: 1 addition & 2 deletions terraform/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ provider "helm" {
# }

provider "github" {
owner = "cis1880"
}

terraform {
Expand All @@ -39,7 +38,7 @@ terraform {
# }
github = {
source = "integrations/github"
version = "~> 6.0"
version = "~> 6.2.3"
}
}
}
9 changes: 7 additions & 2 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ variable "image_pull_pat" {
description = "PAT of GH User to pull gcr images"
}

variable "GH_TOKEN" {
type = string
description = "GitHub Token for the cis1912 GitHub Application"
}

variable "GF_GH_CLIENT_ID" {
type = string
description = "GitHub Client ID for the CIS1880 Grafana OAuth2 Application"
description = "GitHub Client ID for the cis1912 Grafana OAuth2 Application"
}

variable "GF_GH_CLIENT_SECRET" {
type = string
description = "GitHub Client Secret for the CIS1880 Grafana OAuth2 Application"
description = "GitHub Client Secret for the cis1912 Grafana OAuth2 Application"
}

variable "emails" {
Expand Down

0 comments on commit 382b9f8

Please sign in to comment.