Skip to content

Commit 652171d

Browse files
authored
add SonarQube module with configuration options and documentation (#250)
* add SonarQube module with configuration options and documentation * feat: add SonarQube release name variable to module configuration * terraform-docs: automated action * add chart_values input section in SonarQube README * terraform-docs: automated action
1 parent b9bb770 commit 652171d

11 files changed

Lines changed: 448 additions & 0 deletions

File tree

platform/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The following components are included:
1515
- [Reloader](https://github.com/stakater/Reloader)
1616
- [Secrets Store CSI Driver](https://secrets-store-csi-driver.sigs.k8s.io/)
1717
- [Sloth](https://sloth.dev/)
18+
- [SonarQube](https://www.sonarqube.org/)
1819
- [Vertical Pod Autoscaler](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/README.md)
1920

2021
Components are pre-configured to work with each other and support SRE best
@@ -54,6 +55,7 @@ practices.
5455
| <a name="module_reloader"></a> [reloader](#module\_reloader) | ./modules/reloader | n/a |
5556
| <a name="module_secret_store_driver"></a> [secret\_store\_driver](#module\_secret\_store\_driver) | ./modules/secret-store-driver | n/a |
5657
| <a name="module_sloth"></a> [sloth](#module\_sloth) | ./modules/sloth | n/a |
58+
| <a name="module_sonarqube"></a> [sonarqube](#module\_sonarqube) | ./modules/sonarqube | n/a |
5759
| <a name="module_vertical_pod_autoscaler"></a> [vertical\_pod\_autoscaler](#module\_vertical\_pod\_autoscaler) | ./modules/vertical-pod-autoscaler | n/a |
5860

5961
## Resources
@@ -103,6 +105,11 @@ practices.
103105
| <a name="input_secret_store_driver_version"></a> [secret\_store\_driver\_version](#input\_secret\_store\_driver\_version) | Version of the secret store driver to install | `string` | `null` | no |
104106
| <a name="input_sloth_values"></a> [sloth\_values](#input\_sloth\_values) | Overrides to pass to the Helm chart | `list(string)` | `[]` | no |
105107
| <a name="input_sloth_version"></a> [sloth\_version](#input\_sloth\_version) | Version of Sloth to install | `string` | `null` | no |
108+
| <a name="input_sonarqube_enabled"></a> [sonarqube\_enabled](#input\_sonarqube\_enabled) | Set to true to enable SonarQube | `bool` | `false` | no |
109+
| <a name="input_sonarqube_namespace"></a> [sonarqube\_namespace](#input\_sonarqube\_namespace) | Kubernetes namespace for SonarQube. Defaults to the flightdeck namespace if not set. | `string` | `null` | no |
110+
| <a name="input_sonarqube_release_name"></a> [sonarqube\_release\_name](#input\_sonarqube\_release\_name) | Helm release name for SonarQube. Defaults to 'sonarqube'. | `string` | `"sonarqube"` | no |
111+
| <a name="input_sonarqube_values"></a> [sonarqube\_values](#input\_sonarqube\_values) | Overrides to pass to the Helm chart | `list(string)` | `[]` | no |
112+
| <a name="input_sonarqube_version"></a> [sonarqube\_version](#input\_sonarqube\_version) | Version of SonarQube chart to install | `string` | `null` | no |
106113
| <a name="input_vertical_pod_autoscaler_values"></a> [vertical\_pod\_autoscaler\_values](#input\_vertical\_pod\_autoscaler\_values) | Overrides to pass to the Helm chart | `list(string)` | `[]` | no |
107114

108115
## Outputs

platform/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ module "sloth" {
207207
depends_on = [module.prometheus_operator]
208208
}
209209

210+
module "sonarqube" {
211+
source = "./modules/sonarqube"
212+
213+
count = var.sonarqube_enabled ? 1 : 0
214+
215+
chart_values = var.sonarqube_values
216+
chart_version = var.sonarqube_version
217+
k8s_namespace = var.sonarqube_namespace
218+
name = var.sonarqube_release_name
219+
}
220+
210221
locals {
211222
flightdeck_namespace = kubernetes_namespace.flightdeck.metadata[0].name
212223
kube_prometheus_stack_namespace = kubernetes_namespace.kube_prometheus_stack.metadata[0].name
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Requirements
3+
4+
| Name | Version |
5+
|------|---------|
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.8 |
7+
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | ~> 2.4 |
8+
9+
## Providers
10+
11+
| Name | Version |
12+
|------|---------|
13+
| <a name="provider_helm"></a> [helm](#provider\_helm) | ~> 2.4 |
14+
15+
## Resources
16+
17+
| Name | Type |
18+
|------|------|
19+
| [helm_release.this](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
20+
21+
## Inputs
22+
23+
| Name | Description | Type | Default | Required |
24+
|------|-------------|------|---------|:--------:|
25+
| <a name="input_chart_name"></a> [chart\_name](#input\_chart\_name) | Helm chart to install | `string` | `null` | no |
26+
| <a name="input_chart_repository"></a> [chart\_repository](#input\_chart\_repository) | Helm repository containing the chart | `string` | `null` | no |
27+
| <a name="input_chart_values"></a> [chart\_values](#input\_chart\_values) | Overrides to pass to the Helm chart | `list(string)` | `[]` | no |
28+
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Version of chart to install | `string` | `null` | no |
29+
| <a name="input_k8s_namespace"></a> [k8s\_namespace](#input\_k8s\_namespace) | Kubernetes namespace in which resources will be written | `string` | `"default"` | no |
30+
| <a name="input_name"></a> [name](#input\_name) | Name for the release | `string` | `"sonarqube"` | no |
31+
<!-- END_TF_DOCS -->
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"chart": "sonarqube",
3+
"version": "2025.6.1",
4+
"repository": "https://SonarSource.github.io/helm-chart-sonarqube"
5+
}

platform/modules/sonarqube/main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resource "helm_release" "this" {
2+
chart = coalesce(var.chart_name, local.chart_defaults.chart)
3+
name = var.name
4+
namespace = var.k8s_namespace
5+
repository = coalesce(var.chart_repository, local.chart_defaults.repository)
6+
values = concat(local.chart_values, var.chart_values)
7+
version = coalesce(var.chart_version, local.chart_defaults.version)
8+
}
9+
10+
locals {
11+
chart_defaults = jsondecode(file("${path.module}/chart.json"))
12+
13+
chart_values = [
14+
yamlencode(yamldecode(file("${path.module}/values.yaml")))
15+
]
16+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
MODULEFILES := $(wildcard *.tf)
2+
TFLINTRC ?= ../../.tflint.hcl
3+
TFDOCSRC ?= ../../.terraform-docs.yml
4+
5+
.PHONY: default
6+
default: checkfmt validate docs lint
7+
8+
.PHONY: checkfmt
9+
checkfmt: .fmt
10+
11+
.PHONY: fmt
12+
fmt: $(MODULEFILES)
13+
terraform fmt
14+
@touch .fmt
15+
16+
.PHONY: validate
17+
validate: .validate
18+
19+
.PHONY: docs
20+
docs: README.md
21+
22+
.PHONY: lint
23+
lint: .lint
24+
25+
.lint: $(MODULEFILES) .lintinit
26+
tflint --config=$(TFLINTRC)
27+
@touch .lint
28+
29+
.lintinit: $(TFLINTRC)
30+
tflint --init --config=$(TFLINTRC) --module
31+
@touch .lintinit
32+
33+
README.md: $(MODULEFILES)
34+
terraform-docs --config "$(TFDOCSRC)" markdown table . --output-file README.md
35+
36+
.fmt: $(MODULEFILES)
37+
terraform fmt -check
38+
@touch .fmt
39+
40+
.PHONY: init
41+
init: .init
42+
43+
.init: versions.tf .dependencies
44+
terraform init -backend=false
45+
@touch .init
46+
47+
.validate: .init $(MODULEFILES) $(wildcard *.tf.example)
48+
echo | cat - $(wildcard *.tf.example) > test.tf
49+
if AWS_DEFAULT_REGION=us-east-1 terraform validate; then \
50+
rm test.tf; \
51+
touch .validate; \
52+
else \
53+
rm test.tf; \
54+
false; \
55+
fi
56+
57+
.dependencies: *.tf
58+
@grep -ohE \
59+
"\b(backend|provider|resource|module) ['\"][[:alpha:]][[:alnum:]]*|\bsource *=.*" *.tf | \
60+
sed "s/['\"]//" | sort | uniq | \
61+
tee /tmp/initdeps | \
62+
diff -q .dependencies - >/dev/null 2>&1 || \
63+
mv /tmp/initdeps .dependencies
64+
65+
.PHONY: clean
66+
clean:
67+
rm -rf .dependencies .fmt .init .lint .lintinit .terraform* .validate

platform/modules/sonarqube/outputs.tf

Whitespace-only changes.

0 commit comments

Comments
 (0)